I am using the jQuery Chosen plugin and am able to add new options dynamically
$('#element').chosen({
create_option: true,
// persistent_create_option decides if you can add any term, even if part
// of the term is also found, or only unique, not overlapping terms
persistent_create_option: true,
// with the skip_no_results option you can disable the 'No results match..'
// message, which is somewhat redundant when option adding is enabled
skip_no_results: true,
create_option_text: 'Add option'
});
What I need is a way to update a hidden field ONLY IF the Add option link is clicked.
After inspecting the code in Chrome, I can see tthe following html added:
<li class="create-option active-result"><a>Add option</a>: "dsgdsgsdgdg"</li>
I've tried targeting those classes with a click event but it doesn't work
$('.create-option.active-result').click(function() {
alert('fsgsdgdsgd');
});
Is there a way to target this link or check to see if the select list has changed in length?