jQuery Mobile正在删除我的类
我有以下一段HTML:jQuery Mobile正在删除我的类,jquery,html,css,jquery-mobile,Jquery,Html,Css,Jquery Mobile,我有以下一段HTML: <footer data-role="footer" data-position="fixed" data-fullscreen="true"> <div class="top-row"> <div class="content"> <img src="images/default-user.gif" width="45" height="45" alt="" class="avat
<footer data-role="footer" data-position="fixed" data-fullscreen="true">
<div class="top-row">
<div class="content">
<img src="images/default-user.gif" width="45" height="45" alt="" class="avatar left">
<a href="#" id="expand-footer" data-role="none">Expand</a>
</div>
</div>
</footer>
toggleFooter函数由以下函数调用:
$('#expand-footer').on('click', events.toggleFooter);
我遇到的问题是,一旦添加了扩展类,jquerymobile就会将其删除
谢谢我最后这样做了,因为我没有时间真正深入研究这个问题:
toggleButton: function() {
var $btn = $('#expand-footer');
if(footer_expanded) {
$btn.css({'background-position':'left bottom'});
} else {
$btn.css({'background-position':'left top'});
}
}
这是可行的,因为jQuery Mobile没有可以删除的类:)我已经根据您的问题构建了一个新的类。此代码不会删除扩展的类
。如果expanded
真的被删除了,那么一定有其他东西(其他代码)触发了此操作。只需我的2美分,但不应在动画回调函数中使用toggleClass,可能会产生意外的结果。试着改用removeClass()和addClass()方法,看看它是否解决了这个问题。什么调用toggleFooter
?我也试过了。我有一个单独的功能来切换按钮。我只是将它与toggleClass一起发布在这里,以避免粘贴任何其他不相关的代码。它由$(“#expand footer”)调用。on('click',events.toggleFooter);我不确定是否是这种情况,但jquerymobile为可扩展内容提供了名为expand
和contract
的事件。我假设他们对类名使用相同的措辞。您是否尝试过将扩展的
类更改为其他类?我会选择类似于aAFjt2
(完全随机)的东西,以确保这不是问题所在。不过,您应该在这种情况下设置一个JSFiddle,因为似乎是其他原因导致了问题。很多时候,这个问题是一个竞争条件问题,因为jQM是如此AJAXy。它与jQuery Mobile有关。如果我将其从页面中删除,我的代码工作得非常好。但是我需要jQuery Mobile将页脚固定在iPad的底部。@petermk它不是由您显示的代码触发的。修改JSFIDLE并尝试在那里复制它。然后在您的问题中添加到新JSFIDLE的链接。
toggleButton: function() {
var $btn = $('#expand-footer');
if(footer_expanded) {
$btn.css({'background-position':'left bottom'});
} else {
$btn.css({'background-position':'left top'});
}
}