element.bind(“resize.container”, function() { .. } );

发布于 2024-11-28 04:06:10 字数 213 浏览 2 评论 0原文

这是做什么的:

element.bind("resize.container", function() { 
     //.....
});

显然,它是通过调整大小事件调用的,但是 .container 位是做什么用的?

我也没有找到任何关于这种语法“event.bla”的文档——目的是什么?

谢谢, 韦斯利

What does this do:

element.bind("resize.container", function() { 
     //.....
});

Apparently, it gets called with the resize event, but what is the .container bit for?

I also didn't find any documentation about this kind of syntax "event.bla" -- what is the purpose?

Thanks,
Wesley

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

若言繁花未落 2024-12-05 04:06:10

.container 用作命名空间。使用此命名空间,您可以取消元素上 resize 事件的绑定,如下所示。

element.unbind("resize.container");//This will unbind only the handlers which are bound using "resize.container".

element.unbind("resize");//this will unbind all the resize event handlers on this element.

注意:事件命名空间广泛用于插件开发中,以免页面或其他插件绑定在元素上的事件发生改变

Jquery 文档此处

.container is used as a namespace. Using this namespace you can unbind the resize event on element as below

element.unbind("resize.container");//This will unbind only the handlers which are bound using "resize.container".

element.unbind("resize");//this will unbind all the resize event handlers on this element.

Note: event namespacing is widely used in plugin development so as not to alter with the events bound on the element by the page or other plugins

Jquery documentation here

时光与爱终年不遇 2024-12-05 04:06:10

resize.container 是与元素的函数绑定的事件。这似乎是某人创建的自定义事件,名为 $().trigger("resize.container");

resize.container is the event that is getting bound with the function to the element. It seems like a custom event someone created, called like $().trigger("resize.container");

复古式 2024-12-05 04:06:10

如果您查看 bind() 的 jQuery 文档,您会看到以下签名: bind() 是:

.bind( eventType, [eventData,] handler(eventObject) )

因此在本例中 resize.container 是一个 eventType。仅此而已。它不是本机事件(例如,clickchangeload),它是自定义事件。 . 部分是关于命名空间的。您可以在此处阅读有关命名空间事件的信息。

If you look at the jQuery documentation for bind() you see the signature for bind() is:

.bind( eventType, [eventData,] handler(eventObject) )

So in this case resize.container is an eventType. That's all it is. It's not a native event (like, say, click or change or load), it's a custom event. The . part is about namespaces. You can read about namespaced events here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文