Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Selectmenu: Filterable demo now filters/refreshes selectmenu widget #7681

Closed

Conversation

gabrielschulhof
Copy link

Fixes gh-7677

... and actually fixes a bug in the existing selectmenu-custom-filter demo whereby the filter input does not return to the popup if the menu is ever shown as a dialog.

@gabrielschulhof gabrielschulhof force-pushed the 7677-selectmenu-custom-filter-data-filterable branch from 2e61ffd to 800081b Compare September 25, 2014 22:40
// We only handle the appearance of a dialog generated by a filterable selectmenu
if ( !$( ".filterable-select" ).is( function() {
return ( ( $( this ).attr( "id" ) + "-dialog" ) === id );
})) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pretty ugly if why dont we just do $( ".filterable-select" ).attr( "id" ) + "-dialog" !== id?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... because $( ".filterable-select" ) contains multiple elements and we need to check the id of each, not just the first.

Do you think the following alternative is more legible?

var dialogBelongsToSelectmenu = false;

$( ".filterable-select" ).each( function() {
  if ( $( this ).attr( "id" ) + "-dialog" === id ) {
    dialogBelongsToSelectmenu = true;
    return false;
  }
});

if ( dialogBelongsToSelectmenu ) {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another alternative is to keep the check but improve the comment. Something like

// Check all the select menus to see if the id of the dialog matches the id of one of them, because
// we only handle the appearance of a dialog generated by a filterable selectmenu

@gabrielschulhof gabrielschulhof force-pushed the 7677-selectmenu-custom-filter-data-filterable branch from 0720195 to 8af51cc Compare October 24, 2014 12:26
id = page && page.attr( "id" );

$( ".filterable-select" ).each( function() {
if ( ( $( this ).attr( "id" ) + "-dialog" ) === id ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unneeded parens

@arschmitz
Copy link
Contributor

👍

@gabrielschulhof gabrielschulhof deleted the 7677-selectmenu-custom-filter-data-filterable branch October 24, 2014 22:10
gabrielschulhof pushed a commit that referenced this pull request Oct 24, 2014
agcolom pushed a commit to agcolom/jquery-mobile that referenced this pull request Nov 26, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filterable inside custom select: data-filtertext is ignored
4 participants