使用Jquery UI的对话框出现问题

时间:2011-05-19 11:05:38

标签: javascript jquery jquery-ui flot

拨号和位置是调用该函数的html代码中存在的两个分区。 我可以打开它们两个但是在通过“绘图”按钮打开之后无法使用“地点”分区中的绘图嵌入图形。 它只在我最初打开两个方框时才能正常工作。

function abcd (dial,place,xrange){

var dial = conv(dial)

var xr = document.getElementById("xrange");

var yr = document.getElementById("yrange");

var gtype = document.getElementById("pattern");

xr.value = ""; yr.value = ""; gtype.value = "Line" ;

var place = conv(place);

$(dial).dialog("close");

$(dial).dialog("open");

$(place).dialog({
            autoOpen: false,
            show: 'Explode',
            height: 500,
            width: 450,
            modal: true})

$(dial).dialog({
            autoOpen: false,
            show: 'Explode',
            height: 300,
            width: 350,
            modal: false,
            buttons :
                        { "Draw" : function() {
                        $((place)).dialog("open");


            $(function () {

//manipulate input values to plot data

    $.plot(document.getElementById(plac2), [ {data:d1roe,label:"abc"},
                                 {data:d1roa, label:"xyz"} ], {
                  series: {stack: 0},
                  xaxis: {ticks: ticks},
                  ticks: ticks
               });


});

//function open(xyz) {$(xyz).dialog("open");}

function conv (myid) { 
return ( '#' + myid );
 }

2 个答案:

答案 0 :(得分:3)

我想出了一个快速修复它。 问题是对话框将打开但不会被flot操纵,因为它无法提取对话框的宽度和高度。因此,在打开对话框之前,我们可以修复高度和宽度。

在我的情况下,在html样式表中指定高度不起作用。

 $(dial).dialog({
        autoOpen: false,
        show: 'Explode',
        height: 300,
        width: 350,
        modal: false,
        buttons :
                    { "Draw" : function() {
                     $(place).width(500);    // can take this as an input as well
                     $(place).height(500);
                     $(place).dialog("open");
                     //ploting code
}})}

答案 1 :(得分:0)

flot工作所需的关键是你的plac2 div有宽度和高度,并且可见(即绘制到屏幕上)。因此,在绘制之前,请尝试警告您的div是否具有宽度和高度:

var placeholder = document.getElementById(plac2);
alert($(placeholder).width()+','+$(placeholder).height());

//plotting code here

让我们知道会发生什么。