javascript - Dynamically added button only fires "partially" .on('click') -


i have strange behaviour button add via function table. buttons in table this:

<a href="#" class="btn btn-success pointer btn-sm clickable rounded-0" data-ref="detailsraw" data-hash="details-rohmaterial-{{ raw.id }}" data-trigger="{{ raw.id }}"><i class="fa fa-search"></i> details</a>

if click them work expected. if add 1 button dynamically works (for example can see loadrawsettings being fired) , until comment, think class active added removed can see dom updates in chrome dev.

cols functions this:

cols.showmessage = function () {     $('body').addclass('show-message');     messageisopen = true; }; 

while messageisopen , cols global vars.

i'm not sure whether whole 'click' function necessary here anyway:

$(document).on('click', '.clickable', function (e) {      window.location.hash = $(this).attr('data-hash');      /* prepare */     if ($(this).hasclass('active')) {         $('.clickable').removeclass('active');     }     $messagesubleft.html('');     $messagesubright.html('');     $messagecontent.html('');     $messagebutton.hide()         .html('')         .attr('data-title', '')         .attr('data-html', '')         .attr('data-ok', '')         .attr('data-ok-id', '')         .attr('data-id', '')     ;     $messageheader.html($loader);     $message.show();     if ($(this).attr("data-ref") === "detailsraw" && !$(this).hasclass('active')) {         loadrawsettings($(this).attr('data-trigger'));     }      var item = $(this);      if (messageisopen && item.hasclass('active')) {         cols.hidemessage();         cols.hideoverlay();         item.removeclass('active');         $message.html('');     } else {         if (messageisopen) {             cols.hidemessage();             item.addclass('active');             settimeout(function () {                 cols.showmessage();             }, 300);         } else {             /* until here */             item.addclass('active');            cols.showmessage();        }        cols.showoverlay();     } }); 

is there trigegrs function twice maybe? after reload page works fine.


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -