jquery.AreYouSure
jquery.AreYouSure copied to clipboard
rescan()
rescan() needs work
- You are checking for attribute [ays-orig], which is never set anywhere. I guess you only want to pick up fields not existing before.
- Subsequently all matchings fields are rescaned (no problem with this as I want to refresh the values after I have saved the form via ajax), but bind handlers are rebound each time and duplicated.
For my purposes the rescan should be complete, or support a 'all' parameter. Perhaps use namespaces for the events as well. I'm no JS expert, so feel free to question or criticise anything I said :)
var rescan = function(all) {
var $form = $(this);
var fields = $form.find(settings.fieldSelector);
if (!all) fields = fields.not("[ays-orig]");
$(fields).each(storeOrigValue);
$(fields).unbind('change.areYouSure keyup.areYouSure', checkForm).bind('change.areYouSure keyup.areYouSure', checkForm)
};