使用JS輕松實現(xiàn)ionic調用鍵盤搜索功能(超實用)
這個需求是產(chǎn)品提的,一開始只是設置了 <input style="padding-top: 3px;" type="search" placeholder="搜索醫(yī)生或醫(yī)院" ng-model="query">
type="search"
發(fā)現(xiàn)android上可以ios調取不出search健來,氣死我了,經(jīng)過google的搜索得到結論,需要在外面套用一個form表單,于是加上果然好使而且結合了form表單提交的事件直接調用了button 按鈕的點擊事件ng-click="searchSelect()",不需要額外再去監(jiān)聽搜索鍵盤點擊事件,省了一大堆的麻煩,果然很實用啊,我真是個天才
hml代碼如下:
<form> <div class="bar bar-header item-input-inset" style="height: 50px;"> <label class="item-input-wrapper" id="search-input"> <i class="icon ion-ios-search" style="position: relative;color: gray;font-size: 1.5em;top: 1px;"></i> <input style="padding-top: 3px;" type="search" placeholder="搜索醫(yī)生或醫(yī)院" ng-model="query"> </label> <button class="button button-clear" style="color: #49B746;" ng-click="searchSelect()">搜索</button> </div> </form>
js代碼如下:
$scope.searchSelect = function(){ if ($scope.currentSearchType == 'hospital'){ }else{ $scope.search(); } };
以上所述是小編給大家介紹的使用JS輕松實現(xiàn)ionic調用鍵盤搜索功能(超實用),希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關文章
javascript下利用for( in )語句 獲得所有事件名稱的代碼
2008-02-02