This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
How can I add a custom JS file to a backend form? I need to include a google map and then pull out lat/lon which will update the related text input. The plan is to use a partial to show the map, and then the JS to update the inputs.
Cheers,
Adam
Ah ok can that be used in a model partial? I thought it was just pages / layouts? Will give it a bash.
Nope doesn't work, just renders the {% put %} tag and content which makes sense as I've not added a {% scripts %} tag to the admin theme (as I don't want to mess around with that). However it does just let me put normal script tags in so I'll do that in lieu of a "proper" alternative.
Try this:
In your controller add this:
public function __construct()
{
$this->addJs('/plugins/Name/pluginame/assets/js/app.js'); //this should inject app.js
}
Last updated
Hadn't thought of that Ben, but no cigar.
Call to undefined method Illuminate\Database\Query\Builder::addJs()
Last updated
Ah I was using original version from email so was adding to model. Doing it in controller works spot on. Ta!
1-8 of 8