selectize.js icon indicating copy to clipboard operation
selectize.js copied to clipboard

Question: Placeholder plugin with Selectize on IE9 not working

Open chennakrishnaa opened this issue 13 years ago • 7 comments

I tried to put many Placeholder plugins with Selectize but one or the other problem is popped up while testing in IE9. Is there an issue or if it is already tried could you please let me know what is the fix?

chennakrishnaa avatar Sep 25 '13 19:09 chennakrishnaa

Please create a http://jsfiddle.net/ to show the problem.

flamber avatar Sep 28 '13 09:09 flamber

here is the fiddle

http://jsfiddle.net/chennakrishnaa/KQLu5/3/

chennakrishnaa avatar Sep 29 '13 14:09 chennakrishnaa

Okay, so IE9- doesn't support the placeholder attribute. I would recommend that you use help text outside the element if you really need a description, but you could also just ignore it (like rounded corners not showing up in IE8, but newer browsers will show it). Otherwise you need to create your own placeholder library, since the placeholder libraries I can find will conflict with the way Selectize work.

flamber avatar Oct 02 '13 15:10 flamber

Thanks for the response. Could you let me know where exactly it is conflicting? Meanwhile I will try to have my own placeholder solution.

chennakrishnaa avatar Oct 02 '13 21:10 chennakrishnaa

Selectize does a lot of tricks to generate the functionality and flexibility. If you look at the code with Firebug/inspector after initializing selectize, you'll see some of the tricks.

The box looks like a input/select tag, but is actually a construction of a single <input> for typing and several <div>s for display.

The placeholder plugin you're using will actually fill the selectize <input> with placeholder text - that's probably the conflict (I guess).

I've just been playing around - the only way I can make it work-ish is with CSS - it's horrible code: http://jsfiddle.net/m447K/2/

flamber avatar Oct 02 '13 21:10 flamber

In case someone still needs to support placeholders in IE8/9, here is how I managed to get it working with Placeholder Enhanced library.

var togglePlaceholderSupport = function() {
    if (selectize.items.length > 0) {
        // disable placeholder when there is more than one tag
        selectize.$control_input.placeholderEnhanced('destroy');

        // ensure the placeholder text is cleared
        selectize.$control_input.val('');
    } else {
        // enable placeholder when no tags
        selectize.$control_input.placeholderEnhanced({
            normalize: false
        });
    }
};

// add placeholder support
togglePlaceholderSupport();

// check whether to enable/disable placeholder whenever selected items change
selectize.on('change', togglePlaceholderSupport);

// ensure selectize dropdown opens when input is focused
selectize.$control_input.on('focus', function() {
    if (!selectize.$control_input.val()) {
        selectize.open();
    }
});

andrejpavlovic avatar Apr 02 '14 03:04 andrejpavlovic

closing stale issues older than one year. If this issue was closed in error please message the maintainers. All issues must include a proper title, description, and examples.

risadams avatar Nov 11 '20 17:11 risadams