Possible Duplicate:
jQuery Chosen reset
I'm using Chosen plugin on my project.
http://jsfiddle.net/tt13/gFzzc/
The problem is, I can't reset chosen input textbox programmaticaly. How to do it when I click clear button?
Possible Duplicate:
jQuery Chosen reset
I'm using Chosen plugin on my project.
http://jsfiddle.net/tt13/gFzzc/
The problem is, I can't reset chosen input textbox programmaticaly. How to do it when I click clear button?
First of all, you should use the correct version of Chosen, taken from here:
Then, simply reset the value of the select
and trigger "liszt:updated" event:
$("button").on("click", function() {
$(".chzn-select").val("").trigger("liszt:updated");
});
You can try something like this :
Give Id to the button: say clear_chosen
and then trigger close button:
javascript code::
$("#clear_chosen").click(function(){
$(".search-choice-close").click();
});
Write the code inside this block::
$(function () {
$('.chzn-select').chosen();
});
Ugly hack, but works:
Demo: jsfiddle
Code:
$('button').click(function() {
$(".chzn-select").next('.chzn-container').find('.search-choice').remove();
$(".chzn-select").val('');
$(".chzn-select").next('.chzn-container').find('.search-field input').focus();
});