inheritance - OverrideRewrite a javascript library function - Stack Overflow

I am using an open source javascript library timeline.verite.co It's a timeline library which wor

I am using an open source javascript library timeline.verite.co It's a timeline library which works great on page load. But when I try to repaint the timeline on certain condition, it starts giving out weird errors

I would like to modify the init function in the library. But instead of changing it in the original library itself, I would like to rewrite/override this function in another separate .js file so that when this function is called, instead of going to the original function, it must use my modified function.

I'm not sure whether to use prototype/ inheritance and how to use it to solve this problem?

I am using an open source javascript library timeline.verite.co It's a timeline library which works great on page load. But when I try to repaint the timeline on certain condition, it starts giving out weird errors

I would like to modify the init function in the library. But instead of changing it in the original library itself, I would like to rewrite/override this function in another separate .js file so that when this function is called, instead of going to the original function, it must use my modified function.

I'm not sure whether to use prototype/ inheritance and how to use it to solve this problem?

Share Improve this question edited Aug 25, 2012 at 5:36 mplungjan 178k28 gold badges182 silver badges240 bronze badges asked Aug 23, 2012 at 20:28 Neha MNeha M 4631 gold badge5 silver badges14 bronze badges 4
  • What library are you using? What function in said library are you trying to override? Depending on how that function is declared, the method is different. – gen_Eric Commented Aug 23, 2012 at 20:29
  • 3 It really depends on the library, can you provide a link? (Thanks for converting this to a ment!) – techn1cs Commented Aug 23, 2012 at 20:29
  • There is a link on this page, to download the library. timeline.verite.co Its a timeline library which works great on page load. But when I try to repaint the timeline on certain condition, it starts giving out weird errors. – Neha M Commented Aug 23, 2012 at 20:59
  • I'm not sure how to recall the init function. – Neha M Commented Aug 23, 2012 at 21:07
Add a ment  | 

1 Answer 1

Reset to default 5

You only need to assign the new value for it. Here is an example:

obj = {
        myFunction : function() {
            alert('originalValue');
        }
    }

    obj.myFunction();
    obj.myFunction = function() {
        alert('newValue');
    }
    obj.myFunction();

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744084371a4555891.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信