[英]jQuery .load transition and sorttable.js
I have jQuery: 我有jQuery:
$("#loadBtn").click(function(){
$('#div1').delay(200).slideUp('slow')
.load
('page2.php #div2').hide().delay(300).slideDown('slow');
return false;
});
When #loadBtn (located in my #leftColumn) is clicked, it replaces #div1 with #div2 perfectly. 单击#loadBtn(位于我的#leftColumn中)后,它会将#div1完美替换为#div2。 I have two problems with this code however..
我在此代码中有两个问题。
1) SOLVED BY GINCHER ---- I can't get the function to slide up #div1. 1) 由GINCHER解决了 ----我无法获得向上滑动#div1的功能。 it always just instantly fades and slides down #div2.
它总是会立即消失并向下滑动#div2。
If I use jQuery: 如果我使用jQuery:
$("#loadBtn").click(function(){
$('#div1').delay(200).slideUp('slow')
});
that code will slide #div1 flawlessly, however as soon as I add .load('page2.php #div2')
it breaks and fades away before sliding down. 该代码将完美地滑动#div1,但是,一旦我添加
.load('page2.php #div2')
它就会崩溃并逐渐消失,然后向下滑动。
2) SOLVED BY GINCHER ---- I cannot get the tables in #div2 to sort using sorttable.js
2) 由GINCHER解决了 ----我无法使用
sorttable.js
获取#div2中的表进行排序
I realize that scripts ran on page1.php upon load cannot be applied to elements that are loaded via AJAX. 我意识到加载后在page1.php上运行的脚本无法应用于通过AJAX加载的元素。
I have tried to call the new table after the load function is complete, 我试图在加载功能完成后调用新表,
$('#div1').load('page2.php #div2', function() {
var newTable = document.getElementById('#tableId');
sorttable.makeSortable(newTable);
});
But that doesn't work. 但这是行不通的。 Just to see what would happen, I pasted the whole sorttable.js content into
为了看看会发生什么,我将整个sorttable.js内容粘贴到了
$('#div1').load('page2.php #div2', function() { /*sorttable.js content*/}
That made the table work properly, because the function was ran after the content was loaded. 这使表正常工作,因为该函数是在加载内容后运行的。 what am I doing wrong with this?
我在做什么错呢?
$('#div1').delay(200).slideUp('slow', function(){ $(this).load('page2.php #div2').hide().delay(300).slideDown('slow'); });
Do the load function after the slide up completed. 完成滑动后,执行加载功能。
var newTable = document.getElementById('tableId');
- don't add hashtag in getElementById
. -不要在
getElementById
添加井号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.