简体   繁体   中英

How to call callback function of jquery html() method

Below is my jquery code which do following thing:

  1. Load the content form URL and fill into DIV.
  2. Bind the data into html form. Problem: first time, it bind correct data and after each call, it just load the empty form (and data not populated which called through BindForm function as shown below.)

When I tried replace - tag.html with $("#div").load(url,function(){}) then it works but, using below code not work.

Now, I can not change implementation to use load but, any alternative or solution in below code will helpful.

Basically, I need $("<div id=" + diaolgID + "></div>") line to preserve as it is and then load dialog within this.

var tag = $("<div id=" + diaolgID + "></div>");
$.ajax({
    url: url,
    cache: false,
    success: function(data) {
        var htmlContainerObject = tag.html(data);

        htmlContainerObject.dialog({
            modal: true,
            hide: {
                effect: "none",
                duration: 150
            },
            show: {
                effect: "none",
                duration: 150
            },
            title: title,
            width: 950,
            height: 'auto'
        }).dialog('open');

        BindForm();
    }
});

将第一行更改为此:

var tag = $('<div id="' + diaolgID + '"></div>').appendTo('body');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM