Skip to content

Instantly share code, notes, and snippets.

@NaokiStark
Last active April 13, 2016 17:23
Show Gist options
  • Save NaokiStark/fb222ccbe8ef97c757f76336d7c3e58e to your computer and use it in GitHub Desktop.
Save NaokiStark/fb222ccbe8ef97c757f76336d7c3e58e to your computer and use it in GitHub Desktop.
Test = function(){ // para orden, los objetos tienen que comenzar con mayúsculas
this.prop1 = "Hola";
this.metodo1 = function (){
console.log('esta funcionando el metodo');
}
var then = this; //*Magia negra*
$('select').change(function(){
then.metodo1(); //WOW
//Y podemos usar el this para este objeto jQuery
//$(this).hide();
});
}
// var objeto1 = new test(); mi codigo no funciona y no sé por qué, declaramos "TEST" y llamamos a "test", que clase de brujería es esta?
var objeto1 = new Test();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment