Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/support preselection and caption on options #401

Conversation

kayhadrin
Copy link
Contributor

  1. Add ability to make an option pre-selected from dataprovider().

    var data = [
        { label: 'Cheese', value: 'cheese', selected: true },
        { label: 'Tomatoes', value: 'tomatoes' }
    ];
    $('multiselect').multiselect('dataprovider', data);
  2. Add ability to set a title attribute on the option LABEL tags (visible on hover) from the OPTION[title] attribute.

    You can do it with the raw HTML select box:

    <select id="example54" multiple="multiple">
      <option value="cheese" title="Smelly">Cheese</option>
      <option value="tomatoes" title="Handsome">Tomatoes</option>
      <option value="mozarella" title="Italian">Mozzarella</option>
    </select>

    Or you can do it with dataprovider() as follow:

    var data = [
        { label: 'Cheese', value: 'cheese', caption: 'Swiss cheese' },
        { 
          title: 'This is an optgroup title',
          children: [
            { label: 'Cheese', value: 'cheese', caption: 'Smelly' },
            { label: 'Tomatoes', value: 'tomatoes', caption: 'Handsome' }
          ]
        }
    ];
    $('multiselect').multiselect('dataprovider', data);

…ded data

Just set the 'selected' property to true on the data item
Works also for optgroup's options.

Also use jQuery tag constructor and attribute setter to avoid HTML filtering issues
…to display a title on hover of each option label

Update doc
…any string escaping issue

Factorise some code too
@davidstutz
Copy link
Owner

Just for reference: #385 does also add titles for options.

davidstutz added a commit that referenced this pull request Oct 13, 2014
…and-caption-on-options

#385, #384: titles for options, supporting dataprovider; dataprovider with preselected options.
@davidstutz davidstutz merged commit 4690752 into davidstutz:master Oct 13, 2014
@davidstutz
Copy link
Owner

Thanks for your work!

@kayhadrin kayhadrin deleted the features/support-preselection-and-caption-on-options branch October 13, 2014 13:22
@kayhadrin
Copy link
Contributor Author

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants