I am using the widget factory from jQueryUI. I want to access the options hash from within a callback. Inside the callback [_submitMakeHandler], 'this' is a reference to the clicked element.
options: {
model: {
vehicleSelections: ko.observable({
year: ko.observable(),
make: ko.observable(),
model: ko.observable(),
submodel: ko.observable(),
engine: ko.observable()
})
}
},
_cacheMakes: function () {
var 开发者_Python百科jqXHR = $.when($.getJSON('VehicleSelection/GetMakes2'));
jqXHR.then([this._loadMakes, this._templateMakes, this._submitMakeHandler]);
},
_submitMakeHandler: function (data) {
$('#formMakeSelection').delegate('a', 'click', function (e) {
debugger;
e.preventDefault();
var container = $(this).closest('div.flyout');
var link = container.data('el');
$(link).text(this.text);
//******* How do I properly access the options from here?????
});
}
Thanks for any help or tips & tricks. I did try this and it works but it seems like the wrong way to be doing it.$.ui.widgetName.prototype.options
Cheers,
~ckA lot of code here, I will skip to the meat: http://api.jquery.com/jQuery.proxy/
$.widget('ui.widget',{
_submitMakeHandler: function( data ){
$("#formMakeSelection").delegate( 'a', 'click',
$.proxy( this, '_secretMethod' ) );
},
_secretMethod: function( event ){
event.preventDefault();
var container = $( event.target ).closest( 'div.flyout' );
var link = container.data( 'el' );
//*********** Access this.options
console.log( this.options );
}
});
精彩评论