0

I am cloning a select element which trigger a custom event "combobox".

when I clone the select element, custom events are not cloned.

<select id="country">
    <option value="Australia">Australia</otpion>
    <option value="China">China</otpion>
    <option value="Russia">Russia</otpion>
</select>

$('#country').change(function() {
         $(this).trigger($.Event('combochange'));
});     
$('#country').bind('combochange',function() {
         alert($(this).val());
          var clone = $(this).clone(true);
          clone.appendTo('body');
          clone.change();
}); 

Jsfiddle

7
  • you should provide a jsfiddle which replicates your issue Commented Mar 29, 2014 at 14:09
  • I have edited the question. I know that select clone true doesnot clone the status, But what about the custom events Commented Mar 29, 2014 at 14:35
  • clone.appendTO ??? Fix that and it should work Commented Mar 29, 2014 at 14:38
  • Oh! I made a mistake. I change it to appendTo Commented Mar 29, 2014 at 14:48
  • But then what is your issue??? EDIT: i see your are cloning element but not changing ID, IDs must be unique on document context Commented Mar 29, 2014 at 14:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.