Sunday, 15 April 2012

javascript - How to add an event to jQuery's on() callback? -


I tried to:

  $ ('body'). On ('click', '.headerCheckbox', function) {// Add event here and should be magic? Event.stopPropagation (); // Event output in firebug: Event: [object object] Header check box ($ (this ));});  

This is a table, where one of my columns has a checkbox in the header. I want to stop blurring the event so that the table does not get the event, so this column Not like.

I thought it was the right path, but after adding the line, the table is still stable. I can not find a good example to work with it.

Workaround Dataset disabling the sorting on the specified column. DataTable ({"Order": [[1, "desc"]], "column def": [{"targets": 0, "column" orderable ": false}]});

A. Wolff thought the answer to the question was because it was because I wrote (3) with 3 parameter version instead of 2, which I am using, so I did not even think about it.

If your data headers are stable, then you should be able to force the event directly on the checkbox:

  $ ('.headerCheckbox') ('Click', function) {event.stopPropagation (); HeaderCackboxClatch ($ (this));});  

How the delegation works by using event bubbing , (Filtering by using this event goal), so in fact you were blocking the promotion at the body level. The header click event was already removed, and so the sorting method has already been called .


No comments:

Post a Comment