javascript - Is it not a right way to call my obj function? -
i have function return object. in object have 2 function show popup , close it. works within parent function, it's not out side.. not right way call that.. else how can call obj function out side?
my function :
var popuphandler = function(handler,msg,popup){ msg = msg == "help" ? "help" : "results" $(handler).click(function(){ popobj.showpop(); //works }) $('.cls-how2play').click(function(){ if(msg == 'help') popobj.closepop(); //works }); var popobj = { showpop : function(){ if(!(popup).is(':visible')) $(popup).fadein().children().find('.'+msg).show().siblings().hide(); }, closepop : function(){ $(popup).fadeout() } } return popobj; }
from calling ouside :
$('.ui-footer').click( function(){ var closeit = popuphandler(); closeit.popobj.closepop() }) //not works.. why? }
any 1 can me right way call obj functions outside of returning function?
thanks.
as returning popobj
, closeid
2 functions, not wrapped in popobj
object. therefor call function so, without popobj
:
closeit.closepop();
Comments
Post a Comment