Reputation: 636
box_tpv1 = {
box:$("#box_tpv1"),
open:function(mensaje,f_ok,f_x){
this.box.show()
}
}
And when I call this box_tpv1.open() won't work, but If I write inside open function $("#box_tpv1").show() it works.
Upvotes: 0
Views: 108
Reputation: 636
I don't know why but I solved it this way, I can get with this.box the value inside the object methods but doesnt work the jquery selector, if I do that it works
box_tpv1 = {
box:"#box_tpv1",
open:function(mensaje,f_ok,f_x){
$(this.box).show()
}
}
Upvotes: 0
Reputation: 66663
In your case, box_tpv1
is a singleton object, which cannot be further instantiated using new
. Which means the value of this
is insignificant.
You might as well simply call box_tpv1.box.show()
inside the open
function.
Upvotes: 1
Reputation: 12705
there might be issues on the context this function is being called and that depends upon from where are you calling this function from try calling like this
box_tpv1.open.call(box_tpv1);
Upvotes: 0