我收到以下错误(使用Firefox 3.5.9):
$("#dragMe_" + myCount).draggable is not a function
$("#dragMe_"+myCount).draggable({ containment: 'parent', axis: 'y' }); Line 231
http://www.liamharding.com/pgi/pgi.php
指向相关网页的链接:http://www.liamharding.com/pgi/pgi.php
点击上面的链接后,请按照:点击2复选框的“R25 + R50 Random Walk
”,然后点击Show/Refresh Graphs
。应显示两个图表,两个图表都有可拖动的细水平红线。
重新打开选项面板并取消选择R50 Random Walk
,再次点击Show/Refresh Graphs
,删除1个图表,更新另一个图表;现在重新选择R50 Random Walk
并点击Show/Refresh
,R25 graph
更新正常,然后出现上述错误,我无法找出原因。
最初,当显示前两个图表时,它使用相同的代码,它可以正常工作。
此行发生错误:
//********* ERROR OCCURS HERE **********
$("#dragMe_"+myCount).draggable({ containment: 'parent', axis: 'y' });
以下是Show/Refresh Graphs.click() event
的代码:
$("#btnShowGraphs").click(function(){
// Hide 'Options' panel (only if open AND an index is checked)
if (IsOptionsPanelOpen && ($("#indexCheck:checked").length != 0)) {$('#optionImgDiv').click();};
var myCount = 0;
var divIsNew = false;
var gif_loader_small = '<div id="gif_loader_small"></div>';
var gif_loader_big = '<div id="gif_loader_big"></div>';
$("input:checkbox[id=indexCheck]").each(function() {
if (this.checked) {
// check for an existing wrapper div for the current forex item, using the current checkbox value (foxex name)
if ( $("#"+this.value).length == 0 ) {
console.log("New 'graphContainer' div : "+this.value);
divIsNew = true;
// Create new divs for graph image, drag bar and heading
var $structure = " \
<li id=\""+this.value+"\" class=\"graphContainer\"> \
<div id=\"dragMe_"+myCount+"\" class=\"dragMe\"></div> \
<div id=\"image_"+myCount+"\" class=\"image\"></div> \
<div id=\"heading_"+myCount+"\" class=\"heading\"></div> \
</li> \
";
$('#graphResults').append($structure);
// Hide dragMe DIV
$('#dragMe_'+myCount).hide();
// Make 'dragMe' draggable div
//********* ERROR OCCURS HERE **********
$("#dragMe_"+myCount).draggable({ containment: 'parent', axis: 'y' });
}
// Display small loading gif
$(gif_loader_small).clone().appendTo( $(this).parent() );
// Display large circular loading gif
var $loader = $(gif_loader_big);
// add temporary css attributes onto existing graph divs as they need to be displayed diffrently
if(!divIsNew){
console.log("Reposition existing 'gif_loader_big' div");
$loader = $(gif_loader_big).css({
"position" : "absolute",
"top" : "35%",
"opacity" : ".85"});
}
// add newly styled big-loader-gif to index div
$loader.clone().prependTo( $("#"+this.value) );
// Call function to fetch image using ajax
get_graph(this, myCount, divIsNew);
} else {
// REMOVE 'graphContainer' DIVS NOT CHECKED
// check for div existance
if ( $("#"+this.value).length != 0 ) {
console.log("DESTROY: #dragMe_"+myCount+", REMOVE: #"+this.value);
// DESTROY draggable
//$("#dragMe_"+myCount).draggable("destroy");
// remove div
$("#"+this.value).remove();
}
}
// reset counters and other variables
myCount++;
divIsNew = false;
console.log("Complete: "+this.value+", NEXT index");
});
});