Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I add Javascript code to a Luci model page? #1

Open
rubo77 opened this issue Jul 21, 2014 · 3 comments
Open

How can I add Javascript code to a Luci model page? #1

rubo77 opened this issue Jul 21, 2014 · 3 comments

Comments

@rubo77
Copy link
Contributor

rubo77 commented Jul 21, 2014

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.

@rubo77
Copy link
Contributor Author

rubo77 commented Jul 21, 2014

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?

@seamustuohy
Copy link
Owner

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

@seamustuohy
Copy link
Owner

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants