Search code examples
javascriptjqueryarraysclickdetach

Problem when put a element in array, using detach and append to another element using jquery click doesn't work


Having a problem , can't explain because not sure what is happening. Just can only simplify the problem in this example

What hapening

I'm putting the element in a array temporally, then when I put again doesn't have the click event.

How to test

  1. Use "click me" button, will show the alert
  2. detach, will change place
  3. will appear the button "click me" in another place
  4. click on the "click me" button , doesn't work

Solution

  • You should pass true to clone method in order to preserve the events.

    Take a look http://jsfiddle.net/7ZBtZ/2/