Uncaught Error:

ans66

Utente Attivo
27 Ago 2011
158
0
16
Buon giorno a tutti e Buon Anno!

Non riesco ad eliminare il seguente errore "Uncaught Error: cannot call methods on dialog prior to initialization; attempted to call method 'open' " quando avvio la mia Dialog con ProgressBar (codice che segue):

JavaScript:
jQuery(document).ready(function($){

$('body').append("<div id='myDialog'><div id='myProgressBar'></div></div><button id='downloadButton' style='visibility: hidden'></button>");
var myD="";

//$("#downloadButton").click(function(){
myD= MyDlgProgressBar();
myD.dialog("open");

//});

function MyDlgProgressBar ( ){

 var p=0;
 var myDlg= $("#myDialog").dialog({
        height: 100,
        width:500,
        modal: true,
        closeOnEscape: false,
        draggable: false,
        resizable: false,
        autoOpen:true,
        position: {
                    my: "center",
                    at: "center",
                    of: $("body"),
                    within: $("body")
                        } ,
        open: function(event, ui) { DoProgressBar();   } ,
        close: function (event, ui) {
            $("#myDialog").dialog('close');
        }
    }).prev(".ui-dialog-titlebar").css("background","#D0D0D0");
    
   function DoProgressBar() {
    $("#myProgressBar").progressbar({value:0.1});
    var timer=setInterval(function(){
            
            $("#myProgressBar .ui-progressbar-value").animate({width: p+"%"}, 500);
          
                      
            if(p>100){
                $("#myProgressBar .ui-progressbar-value").animate({width: "100%"}, 500);
                
                clearInterval(timer);
                $("#myProgressBar").progressbar( "value", false );
                if ($("#myDialog").dialog('isOpen') === true) {$("#myDialog").dialog("close"); }
            } else { if ($("#myDialog").dialog('isOpen') === true) { $("#myDialog").dialog( "option" , "title" ,"Percentuale: "+p+"%"); } }
            
            p = p +1;
    },500);
 
  }

return myDlg;
    
}
 
});

Grazie per l'aiuto
 

ans66

Utente Attivo
27 Ago 2011
158
0
16
Ho risolto con seguente modifiche:

Codice:
jQuery(document).ready(function($){

var myDlg="";
$('body').append("<div id='myDialog'><div id='myProgressBar'></div></div><button id='downloadButton' style='visibility: hidden'></button>");

 
    myDlg= $("#myDialog").dialog({
        height: 100,
        width:500,
        modal: true,
        closeOnEscape: false,
        draggable: false,
        resizable: false,
        autoOpen:false,
        position: {
                    my: "center",
                    at: "center",
                    of: $("body"),
                    within: $("body")
                        } ,
        open: function(event, ui) { DoProgressBar();  } ,
        close: function (event, ui) {
            $(this).dialog('close');
        }
    }).prev(".ui-dialog-titlebar").css("background","#D0D0D0");
 
    
   function DoProgressBar() {
    $("#myProgressBar").progressbar({value:0.1});
    var p=0;
    var timer=setInterval(function(){
            
            $("#myProgressBar .ui-progressbar-value").animate({width: p+"%"}, 500);
            p = p +1;
                      
            if(p>100){
                $("#myProgressBar .ui-progressbar-value").animate({width: "100%"}, 500);
                
                clearInterval(timer);
                $("#myProgressBar").progressbar( "value", false );
                if ($("#myDialog").dialog('isOpen') === true) {$("#myDialog").dialog("close"); }
            } else { if ($("#myDialog").dialog('isOpen') === true) { $("#myDialog").dialog( "option" , "title" ,"Percentuale: "+p+"%"); } }
            
            
    },500);
 
  }



$("#myDialog").dialog("open");



 
});
 
Discussioni simili
Autore Titolo Forum Risposte Data
F Uncaught (in promise) Error: 3000ms timeout exceeded Javascript 0
T [PHP] aiuto....Fatal error: Uncaught Error:non riesco a capire PHP 1
G Fatal error: Uncaught Error: Call to undefined method UserController PHP 0
G Fatal error: Uncaught exception 'PDOException' PHP 12
R Aiuto: Uncaught SyntaxError: Unexpected token WordPress 2
V Uncaught TypeError: Failed to execute Javascript 0
G Uncaught SyntaxError: Unexpected token ILLEGAL Javascript 1
Marcolotto HTMLCollection: Uncaught TypeError: Illegal constructor Javascript 0
B Uncaught TypeError: Cannot read property Javascript 7
A Uncaught TypeError: Object [object Object] has no method 'cycle' jQuery 1
S 404 Error " Page not Find" Error SEO e Posizionamento 0
L Error Code: 1215. Cannot add foreign key constraint MySQL 3
M HTTP Status 500 - Internal Server Error. Java 0
U Campo vuoto data errore Fatal error: PHP 2
W ADODB.Recordset error '800a0bb9' Classic ASP 2
D error text in table HTML e CSS 11
W Microsoft OLE DB Provider for Visual FoxPro error '80040e14' Function name is missing ). Classic ASP 0
W Parse error: syntax error, unexpected '$result' (T_VARIABLE) PHP 4
W Errore di run-time di Microsoft VBScript error '800a0035' Impossibile trovare il file Classic ASP 0
G Upload file error Apache 0
A Server Apache immagine not found (ERROR 404) Apache 5
D [PHP] Fatal error: Class 'COM' not found in C:\..... PHP 6
T MySQL ERROR 1064 MySQL 1
T [PHP] ...Parse error che non c'è... PHP 7
C [PHP] Errore "Fatal error: Call to undefined function getTotalUsers()" PHP 2
V [MySQL] You have an error in your SQL syntax MySQL 1
G PHPMailer: SMTP error Gmail PHP 8
G [WordPress] [PHP] Parse error: syntax error, unexpected '$x332cbce1' WordPress 2
I [PHP] Login Facebook SDK returned an error: No URL set! PHP 0
bubino8 [PHP] Query syntax error PHP 6
J [PHP] Recoverable fatal error: PHP 4
momeraths [WordPress] cURL error: problema aggiornamento/installazione plugin WordPress 4
A [PHP] FPDF error: Some data has already been output, can't send PDF file PHP 5
otto9due Error anomalo durante invio dati $.ajax Ajax 20
J [PHP] fatal error PHP 1
N [PHP] problema Parse error in file configurazione PHP 3
F Console Error jQuery 1
C PHP errore Fatal Error: Allowed Memory Size of ... Bytes Exhausted PHP 7
K [ASP] Errore: ADODB.Field error '800a0bcd' Classic ASP 1
Z HTTP ERROR 500 - La pagina non funziona - Joomla! Joomla 0
U [PHP] Fatal error: Call to a member function Query() PHP 1
U [PHP] Parse error: syntax error, unexpected variabile (T_VARIABLE) PHP 8
C [PHP] internal error paypal PHP 6
ANDREA20 [PHP] syntax error, unexpected PHP 4
Fuego2806 [PHP] Errore 500 Internal Server Error - sito Joomla! Joomla 10
ANDREA20 [PHP] syntax error, unexpected T_ELSE [era]urgentissimo] PHP 15
A [PHP] syntax error, unexpected T_STRING su html PHP 11
Antoyosh Fatal error con Wordpress WordPress 5
C Errore 500 (internal server error) PHP 1
G Parse error: syntax error, unexpected '=' PHP 2

Discussioni simili