jquery mobile search option

心不动则不痛 提交于 2019-12-13 04:29:10

问题


<!DOCTYPE html>
<html>
<head>
<title>colls</title>
<link rel="stylesheet" href="./jq/jquery.mobile-1.4.0.css" />
<script src="jquery.js"></script>
<script src="./jq/jquery.mobile-1.4.0.js"></script>
<script src="pay.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

</head>
<body>
<header data-role="header"  data-theme="b">

<h1>liste 1</h1>
</header>
<div  data-role="content" data-theme="b">
<form class="ui-filterable">
<input id="filterBasic-input" data-type="search"  placeholder="votre pays" >
</form>
<div  data-filter="true" data-input="#filterBasic-input"data-theme="b"datainset="true">


<div data-role="collapsible">

<h2><span>alsace</span> <a class="gene02 ui-btn-right"data-role="button"
data-inline="true" data-mini="true" data-icon="search">generique</a></h2>
<p>code:3300</p>
<p class="pays">france</p>

and this is my script

$(document).ready(function() {
$(".gene02").click(function() {    
var $hui= $(this).closest('div').find('.pays').html();  
$("#filterBasic-input").val($hui).submit();
});

});

when i click on .gene02 it submit the result and filter it but the value of the imput is blank and the clear button didn't appear. any help please.

when i remove .submit from my script the value change but it is not filtered. thx for help


回答1:


First of all, dont use .ready() in jQuery Mobile, use pagecreate instead.

Secondly, you need to trigger filterable manually on the div which contains filterable data.

HTML

<div id="filter" data-filter="true" data-input="#filterBasic-input" data-theme="b" datainset="true" >

JS

$(document).on("pagecreate", function () {
  $(".gene02").on("click", function () {
    var $hui = $(this).closest('div').find('.pays').html();
    $("#filterBasic-input").val($hui);
    $("#filter").filterable("refresh"); /* this */
  });
});

Demo



来源:https://stackoverflow.com/questions/20971913/jquery-mobile-search-option

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!