ajax 和 tweenmax 的组合

the combination of ajax and tweenmax

http://lifeto.dothome.co.kr/xe/page_FIsv96

在上面的页面中,我使用以下代码调用了 ajax.load:

jQuery(".open_list").on("click", function (e) {
 e.preventDefault()
 jQuery(".ajax_list").fadeOut(function () {
  var $item = jQuery(this)
  $item.load ("http://lifeto.dothome.co.kr/xe/free", function () {
   $item.fadeIn ()
  })
 })
})

...并且在加载的文档 (http://lifeto.dothome.co.kr/xe/free) 中,它包含一个名为 open_contents 的带有 class 的元素。当我点击它时,它会打开一个新的 div.

jQuery('.open_contents').click(function() {
 TweenMax.to (".board_contents", 0.5, {opacity: 1, top: 200,  ease: Bounce.easeOut})
})

有两个问题:

  1. 当我点击带有open_contentsclass的标题(数字1、2、3)时,不会启动Greensock代码滑动从顶部向下。 (我只是假设这是因为加载的 Ajax 无法与 parent window... 交互)

  2. 即使我点击 'close' 按钮,名为 list 的 div 也不会关闭,所以我无法再次打开 .list。

谁能告诉我解决方案?

jQuery('.open_contents').click(function() {

当您运行此代码时,您在当时为文档中的所有元素创建了一个事件侦听器。您需要 运行 在加载元素后(在 $item.load ("http://lifeto.dothome.co.kr/xe/free", function () {...}) 中)或使用(我认为):

jQuery(document.body).on('click', '.open_contents', function () {

只要单击正文中存在 .open_contents class 的任何当前或未来元素,这将 运行。