如何在動態div創建後顯示警報?這樣如何在不重新加載頁面和js的情況下創建動態div後顯示警報?
jQuery("#id").load(function($) {
alert("hello");
});
function methodName(channel){
$.ajax({
type: "get",
dataType: 'html',
data: { param1: param1 , param2: $('#abc').find(":selected").val()},
url: "/xxx/"+ $('.xyz').attr("attr1") +"/yyy",
success: function(data, status){
var obj = JSON.parse(data),
tmplHTML_measures,
data_graph;
var template_data = {
measures_list:
obj.measures
};
$(function() {
tmplHTML_measures = '{{#measures_list}} <div class="col-lg-11 col-lg-offset-1"><p class="indicator-title gray-bottom-border">{{name}}</br></p><div><p><span class="font30px">{{total}} </span> Total {{name}}<br><span class="green-text">{{percentage}}%</span> from last <span class="metric_time"></span></p></div><div class="graph-header"><h3>{{this_interval}} </h3><p>New {{name}}</p><p class="percentage-graph green-text">{{increase}}%<p></div><div id={{graph_id}} class="graph"></div> </div>{{/measures_list}}';
Handlebars.render = function(tmpl, data){data = data || {};return Handlebars.compile(tmpl)(data);};
$("#template").empty().append(Handlebars.render(tmplHTML_measures,template_data));
var data_graph;
for (var measures_cont = 0; measures_cont < obj.measures.length; measures_cont++) {
data_graph = obj.measures[measures_cont];
populateGraph(data_graph.this_interval_detail,data_graph.last_interval_detail,data_graph.graph_id,time_text,obj.bottom_graph_text,parseInt(time.attr('interval')));
}
})
},
error: function(error) {
}
});
return this;
};
這是我的代碼什麼的,我刪除了一些代碼,但這裏是主要的代碼中,我創建的div tmplHTML_measures,正好ID = {{graph_id}}和我填充在populateChart圖表功能。主網頁有大量圖片,所以當在圖片上我畫圖表的用戶點擊,所以我畫一個圖表多次
創建動態的div如何? '.html()''.append()'...? – Zword
我用車把,隨着.append(),但我不能重新加載所有的.js因爲highcharts.js給我的錯誤#16 – Marion