jQuery显示div形成另一页 [英] Jquery show div form another page
问题描述
我有这个问题,我觉得很难解释,但我会尝试:
I have this problem which i find a bit difficult to explain but I will try:
我有一个页面,该页面在单击事件时具有load()
功能,可以淡入和淡出某些其他页面上的divs
. divs
之一包含使用Jquery.Cycle
显示的图片选择.尽管jquery.Cycle
在页面本身上可以正常工作,但是在导入到页面中时却不能.希望我的解释清楚.
I have a page which fades in and out some divs
taken from other pages with the load()
function on click event. One of this divs
contain a selection of pictures showed using Jquery.Cycle
. Although on the page itself the jquery.Cycle
works ok, when imported in to the page it does not. Hope my explanation is clear.
导入代码是这样的:
$('#wrapper a').live("click", function(evt) {
evt.preventDefault();
var url = $(this).attr('href');
var oldDiv = $('#wrapper-content');
var newDiv = $('#wrapper-content1').load(url + ' #wrapper-content');
newDiv.hide();
$('#wrapper-mid-in-right').prepend(newDiv);
newDiv.fadeIn(1000);
oldDiv.fadeOut(1000,function() {
$(this).remove();
});
});
如前所述,循环效果在页面上正常.请帮我. F.
As said the cycle effect works ok on the page. Please help me. F.
$('#gallery').cycle({
fx: 'scrollRight',
timeout: 100000,
speed: 500,
delay: -2000,
pager: '#pager'
});
推荐答案
我相信您的问题与您发布的代码块无关.该插件可以在页面中正常运行,原因如下:
I believe your problem has nothing to do with the code block you posted. The plugin works in the page itself because of a few things:
- 已加载Cycle插件
- 标记已经存在
- 插件已正确启动(
$(document).ready()
等)
- the Cycle plugin is loaded
- the markup already exists
- the plugin is initiated appropriately (
$(document).ready()
, etc.)
将内容动态加载到页面中时,这些事实都不是真的.
When dynamically loading this content into a page, none of these facts may be true.
- 此页面中是否正在加载Cycle插件?
- 导入新标记后,您必须启动Cycle插件.
父页面(加载Cycle内容的页面)中的JS应该大致类似于:
The JS in the the parent page (the page loading the Cycle content) should be something roughly like:
$('#wrapper-content1').load(url + ' #wrapper-content', function() {
$('#gallery').cycle({
fx: 'scrollRight',
timeout: 100000,
speed: 500,
delay: -2000,
pager: '#pager'
});
});
这篇关于jQuery显示div形成另一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!