javascript - Extending require JS like in PHP Classes -
i'm using requirejs. sample code:
psmapa.js file
define('psmapa', ['jquery'], function ($) { 'use strict'; homecoming { map: null, init: function () { console.log('init'); }, init_map: function () { }, customfunc: function () { return; } } });
now in html want extend object, alter customfunc
, add together new ones - this:
<script> define(['psmapa'], function (psmapa) { psmapa.extend({ cutomfunc: function() { console.log('extended'); }, newfunc: function() { } }) }); require(["psmapa"], function(psmapa) { psmapa.init(); psmapa.newfunc(); }); </script>
is possible?
javascript requirejs
No comments:
Post a Comment