luci_tutorials
luci_tutorials copied to clipboard
How can I add Javascript code to a Luci model page?
Maybe you can add a tutorial page for how to enhance your interface files with javascript code?
Maybe you can help here too: http://stackoverflow.com/questions/24864265/add-javascript-in-openwrt-luci-interface
I would like to add a javascript in the gluon webinterface So i you enter a pair of coordinates into one the latitude input field, the logitute part is automatically moved to the other input field.
I found out: you can add some custom javascript in the view for that model.
But I guess, there is a better solution for that?
Yes, you can add custom java-script for the view. Or you can change the "template" attribute of an object to point at a custom template. For a few good examples of this check out the one off classes defined at the bottom of the cbi.lua file.
http://luci.subsignal.org/trac/browser/luci/trunk/modules/base/luasrc/cbi.lua#L1774
Oh and BTW, this would look something like this in the model.
custom_java_script = section:option(DummyValue "none")
custom_java_script.template = "path/to/javascript.js"
custom_html = section:option(DummyValue "none")
custom_html.template = "path/to/html/file.htm"