[英]How to override javascript library function?
I am using Bootstrap datepicker library inside my Symfony application.我在 Symfony 应用程序中使用Bootstrap datepicker 库。 I would like to overwrite the function
updateNavArrows
inside bootstrap-datepicker.js
by removing/commenting line 1132
and 1142
so the prev
cursor which currently disappears(when I am on the page with the startDate
as today) will always be present.我想覆盖功能
updateNavArrows
内bootstrap-datepicker.js
通过删除/注释线1132
和1142
这样的prev
目前消失(当我对页面上的光标startDate
今天)将始终存在。 Is there a better way of achieving this without having to modify the original source code?有没有更好的方法来实现这一点而无需修改原始源代码?
PS: I tried to implement the changes using this answer but it doesn't seem to work. PS:我尝试使用此答案实施更改,但似乎不起作用。
as you can see in the source code here they just remove or add a disabled
class to the next
and prev
buttons你可以在源代码中看到这里,他们只是删除或添加
disabled
类到next
和prev
按钮
this.picker.find('.prev').toggleClass('disabled', prevState);
this.picker.find('.next').toggleClass('disabled', nextState);
this disabled
class just puts the visibility of the button to hidden as you can see here这
disabled
类只是把按钮的知名度,隐藏,你可以看到在这里
.prev, .next {
&.disabled {
visibility: hidden;
}
}
so overriding the css style to set visibility:visible
should work所以覆盖css样式来设置
visibility:visible
应该工作
I have seen something like this before, hope this will help you.我以前见过这样的事情,希望这对你有帮助。
var RealupdateNavArrows = updateNavArrows;
updateNavArrows = function() {
alert("function overrided");
return RealupdateNavArrows();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.