without looking into the code.
from the ui developer guidelines:
Available properties for each instance:
* options: The options for this widget instance, usually a mix of
defaults with settings provided by the user
* element: A jQuery object always containing a single DOMElement,
which can be accessed with this.element[0].
from the dialog documentation:
Code examples
Supply a callback function to handle the open event as an init option.
$('.selector').dialog({
open: function(event, ui) { ... }
});
so to me it would seem that if the ui object is passed around that
there would be a "(this|ui).element" attached to it somewhere, even if
thats not how it's supposed to be ( and probably isn't ), it does make
sense to allow accessing the ui version of the element via that var,
at least for the dialog. where it is used in my script is when i'm
making a dynamic dialog, without using an element that's already in
the dom. like the code below. yes it could be static but this is the
start of a generic modal confirmation dialog which will be called via
a function to populate the title/content, and some content will be
ajax retrieved.
my argument for why this would be good to have "it offers a simple way
to support ajax filled dialogs without having to build an ajax
function in the widget itself to do it". granted you can use e.target,
but that's not documented anywhere in the dialog so it's not
"painfully obvious" to people like myself who always glance at docs
rather than read them.
$('#deleteProduct').click(function (){
var $selfButton = $(this);
$('<div></div>').dialog({
autoOpen: true,
width: 300,
modal: true,
resizable: false,
allowClose: false,
title: 'Delete Product Confirm',
open: function (e){
$(e.target).html('Are you sure you want to delete this product?');
},
close: function (){
$(this).dialog('destroy');
},
buttons: {
'Delete Product': function(){
window.location = js_app_link
('app=products&appPage=default&action=deleteProductConfirm&products_id='
+ $selfButton.attr('products_id'));
},
'Don\'t Delete': function(){
$(this).dialog('destroy');
}
}
});
return false;
});