I have a div in my code, and when I clone it, do not direct fire at the event. Here is the code;
<div id="draggable" onclick="alert(1);" class="ui-widget-content drag"> <p>Drag me to my target</p> </div> <div id="here"> </div> <script type="text/javascript"> $("#draggable").clone().removeAttr("id").attr('id', 'draggable2').appendTo("#here"); $("#draggable2").trigger('onclick'); </script>
When I click on a cloned item, it lights up with a normal event.
If I modify the script to run the source element, it works fine:
<script type="text/javascript"> $("#draggable").clone().removeAttr("id").attr('id', 'draggable2').appendTo("#here"); $("#draggable").trigger('onclick'); </script>
Also the bind function works fine:
<script type="text/javascript"> $("#draggable").clone().removeAttr("id").attr('id', 'draggable2').appendTo("#here"); $("#draggable2").bind('click', function () { alert('2'); }); $("#draggable2").trigger('click'); </script>
Does anyone have an idea on how to launch the "standard" onclick of the cloned element immediately after cloning.
source share