medabida / savy

Ultra-light jQuery plugin that automatically saves form values in the client side and restore them on your next visit
MIT License
22 stars 16 forks source link

Does not work for elements without an ID attribute #5

Closed rajeshgsoni closed 2 weeks ago

rajeshgsoni commented 2 years ago

Hello @medabida, Savy does not work for elements without an ID attribute. I've patched the code locally and this is what I have come up with a workaround for elements that do NOT have an "id" specified.

savy.js line # 6 add this if(!this.id) this.id = $(this).attr("name"); after if (order == "load") { $(this).each(function() {

so final code is if (order == "load") { $(this).each(function() { if(!this.id) this.id = $(this).attr("name"); if ($(this).is(":radio")) { Screenshot 2022-09-27 192853

Hope this helps ~Rajesh