Reputation: 10964
I came across this function recently, I am unsure what the first few lines do.
Could someone possibly explain it to me?
Cheers
jQuery.extend(jQuery.ui.dialog.prototype.options, {
create: function(event) { doSomthing(event); }
});
function doSomthing(event) {
STUFF
}
Upvotes: 2
Views: 64
Reputation: 14620
$.extend
is a jquery function that merges objects together, overwriting any object keys with newer 'versions'.
// Will overwrite the name property. Output in this case is 'john'
// as it overwrites 'dave'
$.extend({name : "dave"}, {name : 'john'});
In the case of the example code you gave, $.extend
is overwriting a prototype object in a jQueryUI dialog widget with a different function, thus changing how the 'dialog' widget behaves when it is created.
Upvotes: 3
Reputation: 3690
It binds call of doSomthing
to the create
event of the jQuery.ui.dialog
or the jQuery.ui.dialog.prototype.options
.
So doSomthing
might be called when you create dialog or option. Not sure if creation of the option is implemented.
Upvotes: 1
Reputation: 11245
jQuery.ui.dialog.prototype.options
is shared field options
for all ui dialogs. More info about prototype inheritance here.Upvotes: 3