Why doesn't my JavaScript pattern work?
For example I try to call the function this.prepare.build(), but it doesn't works. It gives me this error:
this.prepare.build is not a function
<script>
$(function () {
new $.Myfunction();
});
</script>
<script>
(function($) {
'use strict';
function Myfunction(options) {
return new Myfunction.prototype.init(options);
}
Myfunction.fn = $.Myfunction.prototype = {
init: function() {
console.log('call: Myfunction.init')
this.prepare.build();
},
prepare: function() {
return {
build: function() {
console.log('call: Myfunction.prepare.build');
},
run: function() {
console.log('call: Myfunction.prepare.run');
}
}
}
}
Inviter.prototype.init.prototype = Inviter.prototype;
})(jQuery);
</script>
this.prepare().build()