【发布时间】:2012-09-21 05:52:23
【问题描述】:
当表单元素获得焦点时,我试图隐藏页脚。我还想在表单元素失去焦点时显示页脚,模糊事件应该处理。我无法在 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
});
很奇怪,更改事件处理程序会触发,但焦点和模糊不会。
我已经在下面尝试过,但它不起作用 -
$('.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 选择菜单文档,与 google 交谈,在此处搜索,但找不到此问题。
【问题讨论】:
-
嘿伙计,你的更改方法
$('.selectList').change至少有效吗?
标签: jquery html cordova jquery-mobile