Opened 9 years ago
Closed 9 years ago
#10143 closed bug (notabug)
Can't bind to prototypes in _renderItem
Reported by: | spjonez | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | none |
Component: | ui.selectmenu | Version: | 1.11.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
In the original plugin a 'format' function was passed during init to style items. Now it's a global widget call to create a new method. This presents a problem when you are writing function prototypes and do not have (or want) to use the global name to scope callbacks.
Ex: format: function( aItem ) {
return self.textSelectFormatting( aItem );
}
'self' is a reference to the objects 'this' before it has been instantiated. In the original textSelectFormatting would return markup and I could bind a click event to the new markup using the correct scope.
Is this possible with the new design? Or am I stuck binding an event to another object that I can trigger and pass the item that was clicked on to get my object reference?
Change History (2)
comment:1 follow-up: 2 Changed 9 years ago by
comment:2 Changed 9 years ago by
Resolution: | → notabug |
---|---|
Status: | new → closed |
Replying to spjonez:
You can close/delete this, using $( selector ).data( 'uiSelectmenu' )._renderItem = function( aUl, aItem ) seems to work.
fyi you can use $( selector ).selectmenu( "instance" )._renderItem
as of 1.11. See also the approach I used in #10142.
I created an issue to document selectmenu's extension points, because we missed those: https://github.com/jquery/api.jqueryui.com/issues/211. For now you can look at autocomplete method of the same name which is documented (http://api.jqueryui.com/autocomplete/#method-_renderItem), and works the same way.
You can close/delete this, using $( selector ).data( 'uiSelectmenu' )._renderItem = function( aUl, aItem ) seems to work.