javascript - Jquery resizeable only works on the recent(last) dynamically created div -


so have small application in clicking button , adding div dynamically.

here's jsfiddle.

when click "text button" you'll see bootstrap panel being generated. can re-size right or left.

but once add panel clicking button again, second 1 (just added) resizeable old 1 not resizeable more. why happening?

i want them resizeable. have tried best keep id's unique don't clash or create sort of problem.

below javascript code have written button click.

        var richtextdiv = 0; richtextlink.onclick = function (e) {         e.preventdefault();          richtextdiv++;          sortable.innerhtml +='<article id="rich_text_' + richtextdiv + '" class="text">'         +'<div class="panel panel-info richtext_panel **texts** rich_text_panel' + richtextdiv + '">'          +'  <div class="panel-heading">'          +'      rich text'          +'  <button type="button" class="close" onclick="removewidget('+richtextdiv+',\'rich_text_\')" aria-hidden="true">&times;</button>'         +'  </div>' // bootstrap panel heading end          +'<div class="panel-body">'          +'<div class="summernote-'+richtextdiv+'">hello</div>'          +'</div>'                +'</div>'          +'</article>';          $( ".texts" ).resizable({ minwidth: 311, handles: 'e, w' });} 

and sortable div inside body appending seen above , created like:

<div id="content"> <h1 class="title"> canvas </h1> <div id="sortable"> 

also "texts" own class have assigned same div "panel". , calling resizeable "texts". have tried call resizeable unique id's of divs being generated same thing.

i think have provided information if else needed understand problem, happy provide too.

i appreciate , sort out have been stuck problem quite while now.

not sure why doesn't work way did it, works using jquery.appendto() method. here's link fiddle: http://jsfiddle.net/vyxuk/2/

update, after digging, think know why doesn't work. stackoverflow answer suggests "innerhtml detaches existing dom nodes" document. what better, appending new elements via dom functions, or appending strings html tags?

other answer though, can't seem find more information on why :/


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -