我在Quickbase应用程序的页面加载期间加载了一个javascript(hello.js)。单击页面上的“添加”按钮,将调用hello.js,这将打开一个jquery对话框。该对话框有一个进度条,在后台的数据库查询找到填充此对话框下拉列表所需的所有行后,它达到100%。
当我第一次点击“添加”按钮时,这似乎完美无缺。但是,当我第二次单击“添加”按钮时(第一次关闭对话框后),1)对话框打开, 2)也显示html元素(即进度条和finalMessage)。
但是,使用jquery函数无法访问任何元素。我无法更改任何值。
Here is the code of the hello.js :
var $dialog;
var arr_stars = new Array();
var al=0;
$(function(){
var current_url = document.location.href;
var message = '<progress id="progressBar" value="0" max="100" style="width:290px;">
</progress>';
message = message + '<span id="status"> </span> <h4 id="finalMessage">Please wait... </h4>';
message = message + '<label for="lbl_select" id="lbl_select" hidden>STAR#</label>
<select name="dd_starlist" id="dd_starlist" disabled hidden></select>';
$dialog = $('<div></div>')
.html(message)
.dialog({
autoOpen: false,
title: 'Add a STAR',
autoOpen: false,
resizable: false,
draggable: true,
width: 400,
height: 300,
modal: true,
buttons: {
"Add": function() { }
},
close: function() {
$( this ).dialog( "close" );
}
});
$dialog.dialog('open');
progressBarSim(al);
update_dropdown();
})();
function progressBarSim(al) {
var x = document.getElementById("dd_starlist");
var bar = document.getElementById('progressBar');
var status = document.getElementById('status');
status.innerHTML = al+"%";
bar.value = al;
al++;
if(al == 98){
status.innerHTML = "97%";
al=97;
bar.value = 97;
}
var sim = setTimeout("progressBarSim("+al+")",500);
if(x.disabled == false){
status.innerHTML = "100%";
bar.value = 100;
clearTimeout(sim);
al=100;
}
}
function update_dropdown()
{
var timestamp = new Date().getTime();
var url1 = 'XYZ' + timestamp; var i=0;
var x = document.getElementById("dd_starlist");
$.get(url1,function(xml){
$("record",xml).each(function() {
arr_stars[i]= $(this).find('transaction_number').text();
var option = document.createElement("option");
option.text = $(this).find('transaction_number').text();
x.add(option);
i++;
});
x.disabled = false;
var finalMessage = document.getElementById('finalMessage');
finalMessage.innerHTML = "Select a STAR and click Add.";
$("#lbl_select").show();
$("#dd_starlist").show();
});
}