可能?当javascript文件中的函数被触发时,它允许jQuery文件中的一个函数知道? [英] Possible? When a function in a javascript file is triggered, it lets a function in a jQuery file know?
问题描述
我知道这听起来很复杂,但我不能想到另一种方式来做到这一点。
我有新的内容来自javascript文件,这是只有只有无限滚动已知可用于Tumblr。
我有一堆样式发生在传入帖子(http://syndex.me)的布局上,我显然会用jQuery。因此,我处于一种情况,我
A)必须使用.live()(帖子是动态加载的)和
B)不能触发在直接的方式中的变化
在与 DOMNodeInserted
相关的前一个问题中,不情愿地建议。这只是在某些东西被改变的时候听,但是它减慢了这样的页面,并且已被折旧。
编辑
http:// marckremers。 com / syndex / js / jquery.infinitescrollfortumblr.js
是javascript文件(NB这是一个怪物)
http://marckremers.com/syndex/js/jquery.syndex.js
是我的
这样的东西:
jQuery(body)。 (myEvent,function(data){alert(triggered);});
在您的功能中,您可以通知页面
触发器(myEvent,{foo,bar}); $ {pre>
Could I create a function or custom event in a javascript file called "justDidStuff" and then make .live() watch for that being triggered in another jQuery file?
I know this sounds really complicated, but I can't think of another way to do this.
I have new content coming in from the javascript file which is the only infinite scroller known to work for Tumblr.
I have a bunch of styling happening on the layout of the incoming posts (http://syndex.me) which i'm obviously going to make with jQuery. Hence i'm in a situation where I
A) have to use .live() (posts are dynamically loaded) and B) can't trigger the changes in a straightforward manner
In a previous question related to this DOMNodeInserted
was reluctantly suggested. This just listens for when something has been changed, but it slows down pages such as this and has been depreciated.
EDIT
http://marckremers.com/syndex/js/jquery.infinitescrollfortumblr.js Is the javascript file (NB it's a monster)
http://marckremers.com/syndex/js/jquery.syndex.js Is my Styling and Site behaviour jQuery file.
I think you want to use trigger() and bind
Something like this:
jQuery("body").bind("myEvent", function( data ){ alert("triggered"); } );
and in your function you can notify the page
jQuery("body").trigger("myEvent", { "foo", "bar" });
这篇关于可能?当javascript文件中的函数被触发时,它允许jQuery文件中的一个函数知道?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!