nakupanda / bootstrap3-dialog

Make use of Twitter Bootstrap's modal more monkey-friendly.
https://nakupanda.github.io/bootstrap3-dialog/
1.89k stars 664 forks source link

BootstrapDialog.show Remote call is not working continuously #328

Open brijesh-1111 opened 7 years ago

brijesh-1111 commented 7 years ago

Hi Team,

I am new to BootstrapDialog but I have added required Javascript and Css references. Moreover I can able to execute that dialog through sample code given BootstrapDialog.alert('Hi Apple!', function ()...

But I want to use this with MVC 5 ajax request. I have added the piece of Remote call and that is something like below...

BootstrapDialog.show({ size: BootstrapDialog.SIZE_WIDE, message: function (dialog) { var $message = $('#form-dialog-content'); var pageToLoad = dialog.getData('pageToLoad'); $message.load(pageToLoad); return $message; }, data: { 'pageToLoad': url } });

from HTML Side, I have only two div like

`

</div>`

when I execute this I have grid and in that, I have cell with Hyperlink which call this javascript function. It works well when first time I click that cell link. It gives me nice model popup. I can also close that using top crossbar.

But when I click the same link again, I am not getting that call back to server-side. Just to investigate, I added alert inside function (dialog) and I am getting alert continuously but still it didn't call to server after first-time click.

If I replace this code simple with Hi Apple, It gives me dialog everytime I press that link. so, that way I validated that this something inside that Javascript snippet which fails second time onwards.

any idea or suggestion ?

nakupanda commented 7 years ago

Hello,

I think you can change the line

var $message = $('#form-dialog-content');

To

var $message = $('#form-dialog-content').clone();
RimaG commented 7 years ago

It's not working inside a ajax call in web api but jquery alert is working. Please advise. Thanks.

$.ajax({ url: masterUrl + "/controllername/methodname?resultData=" + sendData, type: "POST", data: JSON.stringify(sendData), async: false, datatype: 'json', contentType: "application/json;charset=utf8", success: function (getData) {

        BootstrapDialog.alert(getData);

        alert(getData);

    }

});