vicb/bsmSelect

How to change "title" dynamically

Closed this issue · 4 comments

Hello All,
could anyone tell me how can I change the title in bsmSelect dynamically.

Thanks in advance

dheeban

vicb commented

what's your use case ?

I have this,

    $(document).ready(function () {
        $("#logos").bsmSelect({
            showEffect: function ($el) { $el.fadeIn(); },
            hideEffect: function ($el) { $el.fadeOut(function () { $(this).remove(); }); },
            plugins: [$.bsmSelect.plugins.sortable()],
            title: 'Please select',
            highlight: 'highlight',
            addItemTarget: 'original',
            removeLabel: '<strong>X</strong>',
            containerClass: 'bsmContainer',                // Class for container that wraps this widget
            listClass: 'bsmList-custom',                   // Class for the list ($ol)
            listItemClass: 'bsmListItem-custom',           // Class for the <li> list items
            listItemLabelClass: 'bsmListItemLabel-custom', // Class for the label text that appears in list items
            removeClass: 'bsmListItemRemove-custom',       // Class given to the "remove" link
            extractLabel: function ($o) { return $o.html(); }
        });
    });

I want to change the title (Please select) on a button click event to "Not Needed"

does it helps you?

vicb commented

Yes, it helps, please try this and let me know:

  1. bind the change event of the original select,
  2. retrieve the created select when the event is trigerered bsm = $(this).data('bsmSelect') should do the trick
  3. Update the title and trigger a redraw: bsm.options.title = '...'; bsm.buildSelect();
vicb commented

Not an issue + no feedback