Jquery plugins occupy the same function name -> conflict

后端 未结 3 959
遥遥无期
遥遥无期 2021-01-02 01:56

I\'ve ran into a problem using jquery expose plugin alongside Masked Input plugin. The problem is they both occupy $.mask function which leads to conflict. But

3条回答
  •  温柔的废话
    2021-01-02 02:16

    I think you have a choice between solutions that require you to remember something, the question is how often do you want to remember.

    If you rename one of them then you have to remember to patch any upgrades. I don't think this is such a big deal, it happens all the time in software development.

    An alternative is to pull in one of the plugins and then immediately load a namespace patcher that simply does, for example, jQuery.fn.masked_input = jQuery.fn.mask; and then the expose plugin can be loaded after that. This approach will work as long as the renamed plugin doesn't reference its own name anywhere. And, you'd have to remember the specific loading order for your plugins. This sort of thing also occurs all the time in software development.

提交回复
热议问题