我在我的jQuery手機1.4.0應用程序中有以下可摺疊設置,我需要添加一個動畫到這個可摺疊設置時,它的展開和關閉,我已經試過這個代碼和其在jsfiddle中的工作正常,這是我的jsfiddle,但問題是動畫不適用於我的應用程序與jQuery的移動1.4.0。我如何使這個動畫在jQuery移動1.4.0上工作?請幫助我..可摺疊設置不工作在jQuerymobile 1.4.0的自定義動畫
JavaScript代碼進行動畫
<script>
$('document').on('pageinit',function(){
animateCollapsibleSet($("[data-role='collapsible-set'] > [data-role='collapsible']"));
});
// animation speed;
var animationSpeed = 200;
function animateCollapsibleSet(elm)
{
// can attach events only one time, otherwise we create infinity loop;
elm.one("expand", function() {
// hide the other collapsibles first;
$(this).parent().find(".ui-collapsible-content").not(".ui-collapsible-content- collapsed").trigger("collapse");
// animate show on collapsible;
$(this).find(".ui-collapsible-content").slideDown(animationSpeed, function() {
// trigger original event and attach the animation again;
animateCollapsibleSet($(this).parent().trigger("expand"));
});
// we do our own call to the original event;
return false;
}).one("collapse", function()
{
// animate hide on collapsible;
$(this).find(".ui-collapsible-content").slideUp(animationSpeed, function() {
// trigger original event;
$(this).parent().trigger("collapse");
});
// we do our own call to the original event;
return false;
});
}
</script>
檢查這個http://jsfiddle.net/Palestinian/3LvQh/ – Omar
@OmarThanks它的工作,但有兩個問題:第一個,如果我擴大Governorate1然後展開Governorate2的Governorate1沒」 t自動關閉,我需要點擊它2次才能關閉它當我們點擊前面的例子Governorate2時,我們怎樣才能更新這個代碼,如果Governorate1展開它將自動關閉。 – user
Omar的代碼關閉其他打開的可摺疊的代碼的小更新:http://jsfiddle.net/ezanker/3LvQh/3/ – ezanker