javascript - Jquery confirmation box -


I'm looking for a generic confirmation box which can be used easily by multiple widgets, but I have problems

  (function () {var global = {{Config: config}, rendere: function (caller) {var jqContainer = $ (config.container) ;;; JqContainer .append (config.message); jqContainer.dialog ({button: {'confirm': caller.confirm_action, cancel: caller.cancel_action}})}}}} // end confirmationBox global.testWidget = function () {return {Create_message: function (msg) {var msg = Confirmation box (); Msg.message = msg; msg.render (this);}, Confirm_action: function () {// Please accept Turn off the confirmation verbs here and the confirmation box // Currently not sure how to obtain the confirmation box at this point}, cancel_key: function () {// close the confirmation box and register that cancel // action The widget was canceled with the above, to ensure that how to return it back to the confirmation box back}}} // end testWidget}) (); // Create a widget and a test message var widget = testWidget (); Widget.create_message ('You need to confirm this action to continue');  

Currently, I'm just trying to do something to shut down the box from within the widget, but I think I kept my mind wrapped in the circle. Who knows what that is. Anyone have to help me clean the brain?

Cheers, Sam

The resulting code:

I thought it could be useful for those who later These threads find days in which to look for such a code to find a solution to a similar problem, which I received from the helpful reply here.

As it turns out, in the end it was very easy (as most disappointing mind-spots).

  / ** * The confirmation box is used by a user to confirm the request such as * to delete an item * / global.confirmationBox = function {self} = This; Config = {Container: '& lt; Div & gt; ', message:' ',} return {set_config: config, render_message: function (collar) {var jqContainer = $ (config.container); JqContainer.attr ('id', 'confirmation-dialog'); JqContainer.append (config.message); JqContainer.dialog ({button: {'confirmation': function () {caller.confirm_action (this);}, cancel: function () {caller.cancel_action (this);}}}); }}} // end confirmationBox global.testWidget = function () {return {create_message: function (msg) {var msg = confirmationbox (); Msg.message = msg; Msg.render (this); }, Confirm_action: function (box) {warning ('success'); $ (Box) .dialog ('pass'); }, Cancel_one: function (box) {warning ('cancellation'); $ (Box) .dialog ('pass'); }}} / End testWidget  

for the task of verifying / canceling jqContainer Can pass.

Alternatively, assign the property of the collar to jqContainer. Since the confirmation / cancellation function is called as collar methods, they will have access through the this but it keeps track of one dialog per widget.


Comments