开发者

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

开发者 https://www.devze.com 2023-03-26 09:44 出处:网络
What does this do: element.bind(\"resize.container\", function() { //..... }); Apparently, it gets called with the resize event, but what is the .container bit for?

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


.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


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");


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消