简体   繁体   English

使用Jquery UI对话框的问题

[英]Problem with dialog box using Jquery UI

dial and place are the two divisions which exist in the html code that calls the function. Dial和place是调用该函数的html代码中存在的两个划分。 I am able to open up both of them but not able to embed the graph using plot in the 'place' division after it is opening up via the 'Draw' button. 我可以同时打开它们,但在通过“绘制”按钮打开图形后,无法在“位置”分区中使用绘图嵌入图形。 It works fine only when I open both the boxes initially. 仅当我最初打开两个盒子时,它才能正常工作。

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 );
 }

I figured out a quick fix for it. 我想出了一个快速解决方案。 The problem was that the dialog will open but will not be manipulated by flot because it was unable to extract the width and height of the dialog box. 问题在于该对话框将打开,但由于无法提取对话框的宽度和高度,因此无法通过浮动操作。 So before opening the dialog we can fix the height and width. 因此,在打开对话框之前,我们可以固定高度和宽度。

Specifying height in the style sheet of html did not work in my case. 在我的情况下,在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
}})}

The key thing you need for flot to work is for your plac2 div to have a width and height, and be visible (ie drawn to the screen). 使flot起作用的关键是使plac2 div具有一定的宽度和高度,并使其可见(即绘制到屏幕上)。 So before you plot, try alerting whether your div has width and height: 因此,在绘制之前,请尝试提醒div是否具有宽度和高度:

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

//plotting code here

Let us know what happens. 让我们知道会发生什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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