gpt4 book ai didi

jQuery Mobile 选择菜单焦点和模糊事件不会触发

转载 作者:太空狗 更新时间:2023-10-29 15:51:18 25 4
gpt4 key购买 nike

当表单元素获得焦点时,我试图隐藏页脚。我还想在表单元素失去焦点时显示页脚,这应该由 blur 事件处理。我无法在 jQuery Mobile 选择菜单表单元素上触发焦点或模糊事件。

这是我的表单元素之一的示例 -

<select id="radiology-study-provider" class="selectList"></select>

这是应该在焦点上隐藏我的页脚并在模糊上显示它的 jQuery 代码(它在 DOM 内就绪)-

  $('.selectList').change(function(){
console.log("the change event is firing");
});
$('.selectList').focus(function(){
$('div:jqmData(role="footer")').hide(); // hide the footer
});
$('.selectList').blur(function(){
$('div:jqmData(role="footer")').show(); // show the footer
});

奇怪的是,change 事件处理程序触发但 focus 和 blur 不会。

我已经在下面尝试过了,但行不通 -

  $('.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 - 我已经在 http://jquerymobile.com/test/docs/forms/selects/events.html 查看了 jQuery Mobile 选择菜单文档。 ,与谷歌交谈,在这里搜索,但找不到这个问题。

最佳答案

这就是最终对我有用的东西。

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
}

我在堆栈上看到了这个 - Show hide keyboard is not working propery in android phonegap并注意到您可以收听这 2 个事件。

关于jQuery Mobile 选择菜单焦点和模糊事件不会触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12524976/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com