How to change javascript code so popups open as bPopup, not in new popup window

254 views Asked by At

How to change code below that popup windows open as dpopups (http://dinbror.dk/bpopup/). Now my code opens popups just in a new popup window.

$(document).ready(function() {
    var table = $('#taulu').DataTable( {
        "ajax": "taulu.php",
        "columnDefs": [ {
            "targets": -1,
            "data": null,
            "defaultContent": "<button id='muokkaa'>Muokkaa</button>"
        } ]
    } );
$('#taulu tbody').on( 'click', 'button', function () {

        var data = table.row( $(this).parents('tr') ).data();
        var myWindow = window.open('muokkaa.php?id=' + data[0]+'&saldo='+ data[3]+'&nimi='+ data[1], "", "width=300, height=300");
    } );
}

So just like this above but I want popups to open as bpopup

$('element_to_pop_up').bPopup({
    contentContainer:'.content',
    loadUrl: 'muokkaa.php?id=' + data[0]+'&saldo='+ data[3]+'&nimi='+ data[1]' //Uses jQuery.load()
});

This above is something from document but I can't get it work right.

There is my buttons row by row style Picture shows my html site. I have jQuery already included. Every of those buttons should open dPopup.

1

There are 1 answers

0
sukkis On
$(document).ready(function() {
    var table = $('#taulu').DataTable( {
        "ajax": "taulu.php",
        "columnDefs": [ {
            "targets": -1,
            "data": null,
            "defaultContent": "<button id='muokkaa'>Muokkaa</button>"
        } ]
    } );

        $('#taulu tbody').on( 'click', 'button', function () {
        var data = table.row( $(this).parents('tr') ).data();
        var myWindow = ('muokkaa.php?id=' + data[0]+'&saldo='+ data[3]+'&nimi='+ data[1]);

    $(function ()    {
        $('<div>').dialog({
            modal: true,
            open: function ()
            {
                $(this).load(myWindow);
            },         
            height: 400,
            width: 400,
            title: 'Dynamically Loaded Page'
        });
    });
    } );
}
);

I just used jquery dialog, now it works.