Reputation: 5247
When i am going through the existing code found the below bind function
$('#tnav div[id$="linebox"].linebox').bind("click._ld",function(){
alert('test');
});
In the bind function argument "click._ld" what does _ld means here? i used to find only "click" as argument.
Upvotes: 0
Views: 60
Reputation: 10216
click._ld
means bind the click event handler given a namespace.
As from the jQuery docs:
An event name can be qualified by event namespaces that simplify removing or triggering the event. For example, "click.myPlugin.simple" defines both the myPlugin and simple namespaces for this particular click event. A click event handler attached via that string could be removed with .off("click.myPlugin") or .off("click.simple") without disturbing other click handlers attached to the elements. Namespaces are similar to CSS classes in that they are not hierarchical; only one name needs to match. Namespaces beginning with an underscore are reserved for jQuery's use.
So you could trigger the click handler but just for that one namespace:
$(selector).trigger('click.yournamespace');
One example:
$(selector).bind('click.foo', function() {
alert("foo!");
});
$(selector).bind('click', function() {
alert("foobar!");
});
$(selector).trigger('click'); // alerts foo and foobar
$(selector).trigger('click.foo'); // alerts foo only
Upvotes: 3