Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AJAX URL追加与存储的jQuery.data()冲突_Javascript_Jquery_Debugging_Variables_Reference - Fatal编程技术网

Javascript AJAX URL追加与存储的jQuery.data()冲突

Javascript AJAX URL追加与存储的jQuery.data()冲突,javascript,jquery,debugging,variables,reference,Javascript,Jquery,Debugging,Variables,Reference,我有一个document.ready函数,用于存储所有数据,为:hover上的popover做准备 domReady( function() { $('.foo').each( function() { var el = $(this); var el_content = el.find('[data-content]'); el.data( 'content-attr', { content: el_content, classes: el_classes } );

我有一个
document.ready
函数,用于存储所有数据,为
:hover
上的popover做准备

domReady( function() {
  $('.foo').each( function() {
    var el = $(this);
    var el_content = el.find('[data-content]');
    el.data( 'content-attr', { content: el_content, classes: el_classes } );
  } );
} );
默认情况下,一切正常,但是当为AJAX排序追加URL时,我会丢失我的
窗口
ref,我想,这是因为以下事件处理程序在访问数据时返回
undefined
,而在不追加URL的情况下,访问数据时不会出现问题。我知道这一定是事件处理程序中的
窗口
引用问题,有人能告诉我引用
窗口
的正确方法吗,这样加载时存储数据的jQuery对象就可以访问
.on('hover',function(){//do stuff})在为AJAX附加URL时

$( window ).on( 'hover', '[rel="popover"]', function() {
    var el = $(this);
    var this_content_data = el.data( 'content-attr' ).content;
    function() {
      // do stuff
    }
} );

在这个特定的问题中,我意识到唯一的方法是在初始化视图时将数据存储在jQuery的
.data
属性中,以供
$(window.element.on('hover',…){}

上的函数访问,因为在主体中包含DOM元素,而不是。