doubleclick on row opens a dialog everytime, even if one already present for the same row

doubleclick on row opens a dialog everytime, even if one already present for the same row

capriscapris Posts: 17Questions: 7Answers: 0

Hi Allan,

I have a datatable with 500 to 1000 rows with pagination. on doubleclick of row, opens a dialog with additional details of row. But everytime time i double click it opens a new dialog though there is a dialog present which got intialized with previous dbl click. dbl click even is written on class used for row. iam creating dynamic ID for the dialog when it is created. so each will have dialog with different ID. but when I double click multiple times on same row , there comes a new dialog with same ID(ID has row ID too). my requirement is I can have mutiple dialogs for different rows but not for the same row. Could you pls suggest how to do that.
below is the code used.

//rows are added dynamically to table
$(document).on("dblclick", ".nonlinktd", function (event) {
//alert("sessionrow dblclick");
event.stopImmediatePropagation();
var sessionRowIndex = $("#researchTable-"+clickCount).dataTable().fnGetPosition($(this).parents('tr')[0]);
var sessionAData = $("#researchTable-"+clickCount).dataTable().fnGetData(sessionRowIndex);

var sessionAdtnlInfoDialog =  $('<div id="SessionInfoDialog_'+sessionRowIndex+'-'+clickCount+'"></div>');
sessionAdtnlInfoDialog.dialog({
        title : 'Session AdditonalInfo', modal : true, width : 800,height:300,
        open: function() {
            sessionAdtnlInfoDialog.closest(".ui-dialog")
            .find(".ui-dialog-titlebar-close")
            .html("<span class='ui-button-icon-primary ui-icon ui-icon-closethick'></span><span class='ui-button-text'>close</span>");
        },
        close: function(){
            sessionAdtnlInfoDialog.dialog('close').remove();
        },
        buttons : [ 
                    { id : 'SessionInfoCancelButton_'+sessionRowIndex+'-'+clickCount, text : 'Cancel', 
                        click : function() {
                        sessionAdtnlInfoDialog.dialog('close');  }, disabled : false, 'class':'btn btn-primary'
                    } 
                  ]
}).dialog('open');
var identifiers = '';
var items = sessionAData.additionalSessionInfo.split(',');
for( var i = 0; i < items.length; i++ ) {
    var nvpair = items[i];
    nvpair= nvpair.replace("[", "");
    nvpair= nvpair.replace("]", "");
    var nvarr = nvpair.split(':');
    for( var j = 0; j < nvarr.length; j=j+2 ) {
        identifiers+='<tr><td>'+nvarr[j]+'</td><td>'+nvarr[j+1]+'</td></tr>';
    }
 }

var sessionAddtionalInfo='';
sessionAddtionalInfo+='<h6 style="font-weight:bold;">Additional Session Details:</h6><br/><table class="hoverTable table table-bordered" id="sesionaddtnlInfo-'+clickCount+'" style="width:500px;"><tr><th>Identifier Name</th><th>Identifier Value</th></tr>'+
                            identifiers+'</table>';
sessionAdtnlInfoDialog.html(sessionAddtionalInfo);

});

I dont have the link to share. pls help me on restricting the creation of new dialog for the same row if again doubleclicked without closing the previous one.

This discussion has been closed.