Jump to content


Photo

Prototype: Classes | Indefinida No Ie7


  • Faça o login para participar
1 reply to this topic

#1 pgnall

pgnall

    Enable

  • Usuários
  • 383 posts
  • Sexo:Masculino
  • Localidade:http://eduardo.sganzerla.net

Posted 21/02/2007, 15:41

Bom dia pessoal !!!

Estou com um probleminha no IE7... a classe que eu criei com o prototype( ajax = new cAjax(); ) funciona apenas no Firefox, mas no IE7 diz que 'ajax' não está definido.

Abaixo o código para darem uma analizada.

Ajax.js
//	DEFININDO O AJAX
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
	HttpRequest = new XMLHttpRequest();
	if (HttpRequest.overrideMimeType) {
		HttpRequest.overrideMimeType('text/xml');
	}
} else if (window.ActiveXObject) { // IE
	try {
		HttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			HttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
		} catch(e) {}
	}
}

//	CRIANDO CLASSE "cAjax"
var cAjax = new Class.create();

//	VARIÁVEIS E ARRAYS DA FILA
fila	= [];
ifila	= 0;

//	DEFININDO FUNÇÕES DE AJAX
cAjax.prototype = {	
	//	INICIALIZANDO CLASSE
	initialize: function(){},

	//	ADICIONAR REQUISIÇÕES DO AJAX NA FILA
	Fila:	function(funcao, info1, info2, info3){
		if(info1 == 'undefined') info1	=	0;
		if(info2 == 'undefined') info2	=	0;
		if(info3 == 'undefined') info3	=	0;
	
		fila[fila.length]=[funcao, info1, info2, info3];
		if((ifila+1)==fila.length) funcao();
	},

	//	QUANDO TERMINAR UMA REQUISIÇÃO AJAX CHAMAR ESTA FUNÇÃO
	concluido:	function(){
		ifila++;
		if(ifila+1 ==	fila.lenght)
			fila[ifila][0] ();
	},
	
	//	CORRIGE OS ERROS TRANSMITIDOS PELO AJAX COMO ACENTUAÇÃO E SINAIS HTML...
	corrigir:	function(str){
		retorno	=	str.replace(/\+/g," ");
		retorno	=	unescape(retorno);
		
		return retorno;
	},
	
	//###################################################
	//#	COMEÇO DAS FUNÇÕES DE REQUISIÇÕES AJAX		#
	//###################################################
	//	FUNÇÃO PARA BUSCAR MODELOS DE ACORDO COM O FABRICANTE ESCOLHIDO
	buscar_modelos:	function(){
		...
	}
}

//	INICIANDO CLASSE
var ajax = new cAjax();

Chamada pro ajax
<select name="cbo_id_fabricante_bp" id="cbo_id_fabricante_bp"
	onchange="ajax.Fila(ajax.buscar_modelos, 'frm_busca_padrao', '_bp', 1);">

VALEU

Edição feita por: pgnall, 21/02/2007, 15:43.

Eduardo Sganzerla
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀


www.Eu Sei Escrever.com.br - Adote esta campanha!

#2 Guilherme Blanco

Guilherme Blanco

    Loading...

  • Conselheiros
  • 891 posts
  • Sexo:Masculino
  • Localidade:São Carlos - SP/Brasil
  • Interesses:Programação Web e minha namorada (Maria Camila).

Posted 07/03/2007, 16:10

O Prototype tem problemas ao definir métodos usando prototype. Para isto, existe o Object.extend. Altere seu código e provavelmente funcionará!

[]s,
<script language="WebFórum">
// Dados:
Nome("Guilherme Blanco");
Localidade("São Carlos - SP/Brasil");
Cargo("Manutenção");
</script>




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq