Unable to re-define a function in my javascript object -
i have object defined using literal notation follows (example code used). in external script file.
if (rf == null) var rf = {}; rf.example= { ondosomething: function () { alert('original definition');} , method1 : function(){ rf.example.ondosomething(); } }
in .aspx page have following ..
$(document).ready(function () { rf.example.ondosomething = function(){ alert('new definition'); }; rf.example.method1(); });
when page loads document.ready called alert('original definition');
ever shown. can point me in right direction. want redefine ondosomething
function. thanks, ben.
edit
thanks comments, can see working. matter method1
calling method takes ondosomething()
function callback parameter? e.g.
method1 : function(){ rf.example2.callbackfunction(function() {rf.example.ondosomething();}); }
your code quoted should work (and does: http://jsbin.com/uguva4), other what's in question causing behavior. instance, if you're using kind of javascript compiler (like closure) or minifier or something, names may being changed, case you're adding new ondosomething
when old 1 has been renamed. alternately, perhaps alert being triggered else, not think triggering it. or else may have grabbed reference old ondosomething
(elsewhere in external script, perhaps) , using directly, this: http://jsbin.com/uguva4/2.
Comments
Post a Comment