ACP: JavaScript
-
admin/plugins/awards
... this is your template, from what I can tell.So, if you create a new js file with this inside:
define('admin/plugins/awards', function() { var Awards = {}; Awards.init = function() { // Stuff here is run every time the page is loaded }; return Awards; });
There's no need to include the script tag at the bottom of the template
-
@julian said:
There's no need to include the script tag at the bottom of the template
Except for the require call, right?
-
Not even that, NodeBB automatically tries to load a plugin that is associated with that template, and executes
.init();
if there is one.So with that template above, create a client-side js file (of any name) with the module name defined as I have defined in my last post's code block. Then add it to the
scripts
array in yourplugin.json
so it gets minified on NodeBB start, and then it will be automatically called. -
-
Awards.init = function() { require(['my/public/path/myjs']); };
-
@yariplus said:
Awards.init = function() { require(['my/public/path/myjs']); };
That isn't any different from including the script manually, though.
-
Oh, i see the problem. Dang. There has to be another way then just putting everything in nodebb.min.js though, right?
-
Also I have found another problem - It's a development.
Minification is part of nodebb startup. So after every single change in client JS, you should restart NodeBB, It takes time...
Maybe NodeBB could borrow ideas from Wordpress and handle JS includes for particular pages?
I'm OK with single minified script for production. -
@Nicolas there is a grunt thing that only does what is necessary. You should try it out.
-
grunt --verbose
? It will restart nodebb, nothing very special... -
@pichalite try this
Dropbox error - 'echo 100000 | sudo tee / proc/sys/fs/inotify/max_user_watches'
Dropbox gives me an error that mentions echo tee 100000 but then it disappears. How to fix or remove msg?
Ask Ubuntu (askubuntu.com)