← Back to team overview

openerp-dev-web team mailing list archive

Re: lp:~openerp-dev/openobject-client-web/trunk-prevent-click-before-document-is-ready into lp:openobject-client-web

 

Review: Needs Fixing
* There's commented code commited
* I'd recommend using jQuery.fn.delegate() rather than live() (it's easier to understand, and though that's not really relevant for us it can also be set on an arbitrary root element)
* A `return false` in an event handler combines `e.preventDefault` and `e.stopPropagation`, no need for both
* If you use `.live()` or `jQuery(document).delegate` and don't need to perform specific tests (presence or not of an element for instance) you might as well move the behavior into a JS file instead of leaving it into a template. You're not unbinding the event anyway so…
* Instead of creating one-off preventDefault calls (jQuery('#add_user_widget').live, Query('div#shortcuts a ').live, …) maybe just prefix the jQuery.ready call in openerp.base.js by a blanked preventDefault along the lines of:

    jQuery(document).delegate('a[href]:not([target]):not([href^="#"]):not([href^="javascript"]):not([rel=external])', 'click', function (e) {
        e.preventDefault();
    });

  and undelegate() it right before setting up the "real" event delegation targets?
-- 
https://code.launchpad.net/~openerp-dev/openobject-client-web/trunk-prevent-click-before-document-is-ready/+merge/42473
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-client-web/trunk-prevent-click-before-document-is-ready.



References