codedance / jquery.AreYouSure

A light-weight jQuery "dirty forms" Plugin - it monitors html forms and alerts users to unsaved changes if they attempt to close the browser or navigate away from the page. (Are you sure?)
508 stars 145 forks source link

Checking for the 'name' attribute again #51

Closed amatenkov closed 10 years ago

amatenkov commented 10 years ago

Example. I have a form with hidden field. I use this field for checking complex structure for changes (serialize and write when this structure changes). After writing to field I trigger checkform.areYouSure. As you can see this field without name attribute.

<input type="hidden" id="fiasAddressBoxHash" />

So, AYS does not get value of this field, because function getValue checks for name attribute:

$field.attr('name') === undefined

and return null if it undefined. When I delete this checking it works as expected. In 1.8 and 1.9 branch this checking exists too.

UPD: something works wrong without this checking. UPD2: Facepalm.jpg. It kendoNumericBox input without name and id. It I can fix in my form by setting 'fieldSelector' option, I hope.

codedance commented 10 years ago

This check was added as outlined in this closed issue:

https://github.com/codedance/jquery.AreYouSure/issues/12

I believe we ignore unnamed fields as there is issues with .val(). These fields also don't post on a form so don't really mutate the dirty state. Are you able to add a name attribute to your field?

amatenkov commented 10 years ago

Yes, of course. I already did this.

codedance commented 10 years ago

Can I close this issue, or do you think it needs further investigation or documentation?

amatenkov commented 10 years ago

Yes, close.