Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
in Plugins by
I'm making a plugin and I was wondering if there is any built in way to create a form that has dynamic form fields. For example, user clicks a plus button and a new row appears with several other fields that would then be submitted to the backend. I know how to do this using jquery and simply doing it myself but I was wondering if there was an prebuilt method to accomplish this or even if there's a way to include a custom js file for the affected pages.

If there is not, how could I go about accomplishing this?


I found some stuff on adding js to a layer but I need this js to be added or injected into the admin portion of the plugins page.

To clarify I have found http://www.question2answer.org/qa/9808/adding-javascript-code-to-a-plugin-page which is what I'm sort of looking for but would prefer it to be cleaner (i.e. it's own independent js file located within the plugin folder) assuming this functionality is not already built in.


[Edit 2]

It's been almost an hour and this question hasn't even been approved to be shown. However, after continuing to dig into things I came up with several solutions which I'll list here since I cannot list an answer to the question yet.

Solution 1: $qa_content['head_lines'][] = '<script src="'.$this->urltoroot.'/custom.js"></script>';

Solution 2: $qa_content["script_src"][] = $this->urltoroot.'/qa-widget-anywhere.js';

Still, if there are better solutions to this dilemma I'd still like to hear about them.
Q2A version: 1.7

Please log in or register to answer this question.