Immediately I say in js is rather weak. In general, the question is the following block. In it there is a form which is processed through ajax. I wrote a plugin that copies this block to another location (for me, for example, http://jsfiddle.net/wre1bk27/ ). Accordingly, it already kills all event handlers. The code is simple:

div = $(element).html(); innerdiv = '<li><span class="close"></span>'+div+'</li>'; $(innerdiv).insertAfter(ul.find('li').eq(el_num)); 

In general, hint how to do it right. In my place where the form is inserted a block with an ID, and with this copying I obviously break the DOM.

  • one
    @binliz, he doesn't kill anything. Handlers are hung on specific elements (not on selectors! On existing elements), just copying HTML into the DOM creates a new element — naturally, without handlers. There are two solutions - using .on() , which in this context will be incorrect, and using .clone () , which allows you to copy an element with handlers. - etki
  • well i will slope. the fact is that I get every form that has its own type identifier where id = BX_4954053 is something like this and according to this principle it defines the block that needs to be processed. Sledvenno I get 2 identical ID ?? Do I need to delete the old one? And then when you release to return to the place? There are plugs in the example (I also wrote so don't be scared). - binliz
  • @binliz why do you have id there? is it due to anything? - zb '
  • Yes, unfortunately due to the ajax component of 1C Bitrix. I can invent a bicycle (like sending data to a blank page through a regular jquery, but it’s advisable for me to clone the component code because I already can do this (in the sense of sending data from a form) so as not to invent it. - binliz
  • I basically understood the following from the comments. I need to clone the block, I can clear it as there is already a clone. And then when hiding the window back into place, too, by cloning. Will it work? - binliz

1 answer 1

The @binliz block is transferred for example like this (I'm a bit confused in your code, so I’ll do a separate example):

http://jsfiddle.net/oceog/s20yc9k7/ or so http://jsfiddle.net/oceog/s20yc9k7/5/