[英]access a js function/class from another file
I have the following function/class sitting in a file called "errors.js": 我将以下函数/类放在一个名为“ errors.js”的文件中:
HB.errors.handleErrorResponse = function(data, form, status) {
HB.FormButtons.deactivateButtons(HB.errors.formSubmitButton);
$('#_ignoreDoubleBooking').toggle((status == HB.errors.HTTP_CODE_CONFLICT));
if (data) {
HB.Reservation.Listeners.handle40xResponse(data);
} else {
HB.Reservation.Listeners.handle50xResponse();
}
};
however HB.Reservation.Listeners.handle40xResponse()
is siting in another file within the same directory. 但是
HB.Reservation.Listeners.handle40xResponse()
位于同一目录中的另一个文件中。
What is the best way of obtaining access to "HB.Reservation.Listeners.handle40xResponse()" from errors.js? 从errors.js获得对“ HB.Reservation.Listeners.handle40xResponse()”的访问的最佳方法是什么?
You probably will be interested by requirejs ( http://requirejs.org/ ). 您可能会对requirejs( http://requirejs.org/ )感兴趣。 This is a JavaScript file and module loader.
这是一个JavaScript文件和模块加载器。 The website documentation is very understandable.
网站文档非常容易理解。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.