Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2007
    Messaggi
    7

    [mootools] Bug IE? visibilità (scope) classi

    Sto scrivendo una piccola chat, utilizzando mootools, funziona perfettamente su Firefox, tuttavia su IE7 quando nella pagina .php cerco di richiamarla mi dice Chat non definita.

    file chat.js
    codice:
    
    var Chat = new Class({
    
      initialize: function(usr,usr_to){
       (cut)
      },
    
    getMessage: function(msglog){
    		
        if (!msglog){
    	msglog=false;
       }
        var url = 'ajax/message.php';
    
        var myAjax = new Ajax(url, {
    	method: 'post',
    	data: Object.toQueryString({ usr_to: this.usr_to , i: this.last_poolid }),
    	onComplete: function(txt,xml){
    		msg = Json.evaluate(txt);
    		if (!$chk(msg)){
    		  return false;
    		}
    		el = $('message');
    		for (var i = 0; i<msg.length; i++){
    		  el_row     = new Element('div', { class: 'msg_row' });
                      
                      el_row_usr = new Element('div', { class: 'msg_usr' });
                      el_row_usr.setHTML(msg[i]['cht_from'] +':');
    
                      el_row_msg = new Element('div', { class: 'msg_msg' });
                      el_row_msg.setHTML(msg[i]['cht_msg']); 
                      
                      el_row_usr.injectInside(el_row);
                      el_row_msg.injectInside(el_row);
                     
                      el_row.injectInside(el);
                      this.last_poolid=msg[i]['cht_id'];
             }
         }.bind(this)
    													
       });
       myAjax.request();
    	}
    nel file php chat.php viene istanziata con la seguente funzione:
    codice:
      	window.addEvent('domready', function(){
               cht = new Chat('<?= $usrname ?>', '<?= $usr_to ?>');
    	});
    La cosa bella è che togliendo il blocco "var myAjax = new Ajax(url, {..." la classe viene vista.
    cosa c'è di sbagliato ho dimenticato qualcosa sulla gestione degli oggetti in js da parte di IE?

  2. #2
    Utente di HTML.it
    Registrato dal
    Jun 2007
    Messaggi
    7
    Ok risolto da solo...
    codice:
                 
                     el_row     = new Element('div', { class: 'msg_row' });
                      
                      el_row_usr = new Element('div', { class: 'msg_usr' });
                      el_row_usr.setHTML(msg[i]['cht_from'] +':');
    
                      el_row_msg = new Element('div', { class: 'msg_msg' });
                      el_row_msg.setHTML(msg[i]['cht_msg']); 
                      
                      el_row_usr.injectInside(el_row);
                      el_row_msg.injectInside(el_row);
                     
                      el_row.injectInside(el);
                      this.last_poolid=msg[i]['cht_id'];
    questa partè è incopatibile, pero mi domando ma mootools non dovrebbe essere compatibile con tutti i browser?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.