I was reading an excellent explanation of the jQuery UI combobox by Jörn Zaefferer (here's the link).
The fourth line of code reads var select = this.element.hide()
Jörn says:
The var select references the select element on which the combobox gets applied. To replace the select with the text input, the select is hidden.
I am learning jQuery now, and I don't recall seeing this.element before. How is it different that just this?
Inside a widget, "this" refers to the widget object itself, which contains a property "element". That "element" points to html element for which that widget has been applied.
You can think of it like this.
this.element // is just normal jquery object
// for example
var element = $('.current-selected-dropdown');
// and then put this together inside ui object
this.element = element
I'm not sure if this would help you.
var Dropdown = {
element: null,
_init: function() {
// here is the same this.element that you referred to.
this.element = $('.dropdown');
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With