以前は Modal は関数であり、このように定義されていました
function Modal (heading){
this.modal="Hello"; //works fine
Modal.prototype.show = function(){ // Not working
$('#exceptionModal').modal('show');
}
}
私はそれをrequirejsモジュール用に変換しようとしました
define("wbModal", function(){
return{
Modal: function(heading){
this.modal="Hello"; //works fine
this.prototype.show = function(){ // Not working
$('#exceptionModal').modal('show');
}
}
}
}
何が問題なのかわかりません。this.modal
機能する場合は、機能しないのはなぜthis.prototype.show
ですか?
以下はコンソールで見つけることができます:
Uncaught TypeError: Cannot set property 'show' of undefined