Thursday 15 January 2015

javascript - How can I have a dynamically allocated DOM event fire as well as a backbone event? -


I have to attach a loader to my button on the mouse page on every page.

I have a function that passes the layers in the render and top-level view, after which it grabs every button and attaches a Masudown event to it:

  AttachGlobalButtonEventHandler: function (see) {view. $ El.find $ 'Target.addClass' ('active'); $ Target.prop ('disabled', 'true); }); }   

It works fine, but the problem is that the incidents of my spine are not running on the button, which looks:

  events : {'Click .newtag': 'gotoCreate'}, goto create: function (evt) {evt.preventDefault (); App.router.navigate ('somewhere', true); }   

If I delete attachGlobalButtonEventHandler , then click on newtag OK, but if the handler is connected. How can I ensure that the occurrence of the click on the spinal cord will also be cured?

Here the problem occurs in the disabled property and order events.

MausDown event occurs before the event and in the mousedown callback you disable the button, this Type click delete event altogether.

Check it out. If you comment on line $ (this) .prop ('disabled',); then click the event will fire.

By adding a setTimeout you can execute it effectively on the next tick, check it out for details.

Edit: I have now noticed that @CommanKey had suggested a comment the same thing.

No comments:

Post a Comment