Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery Mobile Select功能表焦点和模糊事件赢得';t火_Jquery_Html_Cordova_Jquery Mobile - Fatal编程技术网

jQuery Mobile Select功能表焦点和模糊事件赢得';t火

jQuery Mobile Select功能表焦点和模糊事件赢得';t火,jquery,html,cordova,jquery-mobile,Jquery,Html,Cordova,Jquery Mobile,当表单元素被赋予焦点时,我试图隐藏一个页脚。我还想在表单元素失去焦点时显示一个页脚,模糊事件应该处理这个问题。我无法在jQuery Mobile selectmenu表单元素上触发焦点或模糊事件 下面是我的一个表单元素的示例- <select id="radiology-study-provider" class="selectList"></select> 奇怪的是,更改事件处理程序会启动,但焦点和模糊不会启动 我在下面试过了,但它不起作用- $('.select

当表单元素被赋予焦点时,我试图隐藏一个页脚。我还想在表单元素失去焦点时显示一个页脚,模糊事件应该处理这个问题。我无法在jQuery Mobile selectmenu表单元素上触发焦点或模糊事件

下面是我的一个表单元素的示例-

<select id="radiology-study-provider" class="selectList"></select>
奇怪的是,更改事件处理程序会启动,但焦点和模糊不会启动

我在下面试过了,但它不起作用-

  $('.selectList').on('focus', function(){
      $('div:jqmData(role="footer")').hide(); // hide the footer
  });
  $('.selectList').on('blur', function(){
      $('div:jqmData(role="footer")').show(); // show the footer
  });
我也试过这个-

   $('.selectList').bind( "focus", function(event, ui) {
       $('div:jqmData(role="footer")').hide(); // hide the footer
  });
   $('.selectList').bind( "blur", function(event, ui) {
       $('div:jqmData(role="footer")').hide(); // hide the footer
  });
我还尝试了focusin()和focusout()事件,但也没有成功。我尝试了几十个选择器(div.ui-select就是其中之一)。我不认为我使用的选择器有问题


我正在使用jQuery Mobile 1.1.0和jQuery 1.7.1-我已在上查看了jQuery Mobile selectmenu文档,与google交谈,在此处搜索,但找不到此问题。

尝试对焦点事件发表评论,然后再试一次。。有时,当焦点事件触发时,它会被多次触发,因为您看不到执行的代码

$('.selectList').change(function(){
      alert("the change event is firing");
  });

 // $('.selectList').focus(function(){
 //    $('div:jqmData(role="footer")').hide(); // hide the footer
 //    alert("Focus event is firing");
 // });

  $('.selectList').blur(function(){
      //$('div:jqmData(role="footer")').show(); // show the footer
      alert("Blur event is firing");
  });​
我对焦点事件进行了评论,其他两个事件似乎都启动了。。 删除注释后,您将看到焦点事件被多次触发


检查使用以下示例对我有效:

JS:

<script>
    document.addEventListener("deviceready", function(){}, false);

    $(function() {
        $('.selectList').change(function(){
            console.log("the change event is firing");                                      
        });

        $('.selectList').focus(function(){
            console.log("FOCUS");
            $('#my_footer').hide(); // hide the footer
        });

        $('.selectList').focusout(function(){
            console.log("FOCUS OUT");
            $('#my_footer').show(); // show the footer
        });
    });
</script>
<body>
    <div data-role="page">
        <div data-role="content">

            <select id="radiology-study-provider" class="selectList">
                <option value="1">A</option>
                <option value="2">B</option>
                <option value="3">C</option> 
            </select>

        </div>
    </div>
</body>
你可以试试这个例子,看看这对你是否有效


希望这有帮助。让我知道你的结果。

这就是我的工作结果

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady () {
    document.addEventListener("hidekeyboard", onKeyboardHide, false);
    document.addEventListener("showkeyboard", onKeyboardShow, false);

}

function onKeyboardHide() {
    $('div:jqmData(role="footer")').show(); // show the footer
}

function onKeyboardShow() {
    $('div:jqmData(role="footer")').hide(); // hide the footer
}

我在stack上发现了这一点,并注意到您可以收听这两个事件。

谢谢您的建议。不幸的是,模糊事件不会触发。我需要知道android键盘何时出现,这可以通过表单元素上的聚焦和模糊事件处理程序实现。嘿,伙计,你的更改方法
$('.selectList')。至少更改
有效吗?非常感谢你的帮助。不过,再一次,只有变更事件想要触发。不过我想出了一个解决办法,我要发布对我有用的东西。欢迎你的朋友:)。我很想知道问题出在哪里:S。。。我将等待你的解决方案:PI必须再等5个小时才能自我回答,因为我的声誉不到10。我明天把它贴在这里。再次感谢你。
document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady () {
    document.addEventListener("hidekeyboard", onKeyboardHide, false);
    document.addEventListener("showkeyboard", onKeyboardShow, false);

}

function onKeyboardHide() {
    $('div:jqmData(role="footer")').show(); // show the footer
}

function onKeyboardShow() {
    $('div:jqmData(role="footer")').hide(); // hide the footer
}