I'm using the so called garber-irish technique for splitting up my javascript files.
My question is, I have a Model (Item say) and have an init function which is in app/assets/javascripts/item/item.js
e.g.
MYAPP.items = {
init: function() {
alert("do something");
}
};
Now.. lets say I have an administration side to this app, and I don't really want to include the admin javascript in the main bulk. So.. I have a different system_adminstration.js which requires the regular javascripts/item/item.js above, but also requires a javascripts/admin/item/item.js which would look something like:
MYAPP.items = {
init: function() {
alert("also do this");
}
};
I want to load both the common javascripts above, and the administation specific ones - effectively merging the two init functions and keeping things nicely dry.
Questions:
- Is this a sensible approach?
- It it possible?