Reputation:
I have the following code:
$.modal({
content: '<p>Are you sure you want to delete?</p>',
title: 'Delete confimation',
maxWidth: 500,
buttons: {
'Yes': function(win) {
win.closeModal();
},
'No': function(win) {
win.closeModal();
}
}
});
Can someone explain what (win) means? I can see it used a few times but I am not sure what it is doing?
Upvotes: 2
Views: 2398
Reputation: 60536
Bottom-up explanation:
It's a variable name to the anon function being passed as the value of key Yes
and No
in the object for buttons
.
Top-down explanation: You are calling modal
plugin and passing an argument to the function which is an object that has 4 members: content
, title
, maxWidth
, buttons
. buttons
is an object (basically you are passing an object inside an object), with 2 members, Yes
and No
, which is are anonymous functions, each with an argument win
.
Basically win
is the instance of the modal you are opening via $.modal()
In this case, pressing both Yes
and No
will simply close the modal without doing anything
Upvotes: 3