Can jQuery click event combine an callback? -
I want to display a confirmation popup with the OK button. Normally, if I do not want a callback, the OK button will hide the popup and layer mask. When I callback, the OK button will do something in the callback function.
Function display Erropop (message, callback) {$ ("# error_popup_message"). Html (message); Display_popup ($ ("# error_popup")); If (callback & amp; typefort (callback) === "function") {$ ("# error_popup_ok") Click (function () {callback ();}); } And {$ ("# error_popup_ok"). Click (function () {hideErrorPopup ();}); }} But callback function calls immediately:
displayErrorPopup ('error message', function (); some; hideErrorPopup ();}) ; Click the OK button event.
Please help me !! Thanks!
function display eropopop (message, callback) {$ ("# error_popup_message") HTML ( message); Display_popup ($ ("# error_popup")); Click $ ("# error_popup_ok") (function () {ifof (callof = type "function" type) {callback ();} else {hideErrorPopup ();}}); } The simplest way would be:
display display erroppop (message, callback) {$ ("# error_popup_message"). Html (message); Display_popup ($ ("# error_popup")); $ ("# Error_popup_ok") Click (type of callback == "function"? Callback: hide errorPopup); }
Comments
Post a Comment