javascript - How to disable Jquery prompt save button on first click -


i using jquery prompt prompt user save. so, user clicks save button, jquery prompt displays , asks if user sure he/she wants save changes or not. problem is, user able click multiple times on jquery save prompt button before prompt closes. result, save routine runs once each time prompt save button clicked, results in duplicate records in database. need disable prompt save button on first click or close prompt window on first click prevent multiple saves. how can this?

client code:

$.prompt("are sure want save? not able change decision after it's been saved.", {     title: "save?",     buttons: { "save": true, "cancel": false },     submit: function (e, v, m, f) {         if (v) {             response = saveupdates(loandetails);         }     } }); 

i created fiddle here: http://jsfiddle.net/smurphy/4fqjr/

the solution little convoluted. thought there simpler way after looking through documentation cannot find built in feature.

here code:

submit: function (value, message) {         if (value) {             $(message.prevobject)                .find('button[value="true"]')                .attr('disabled', true);              //todo: perform save              //response = saveupdates(loandetails);         }     } 

the message param reference text description can find button navigating around dom starting point.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -