Thanks to Paul, iTorrey, Gregor, nkrisc, zeroskillz, and a number of other intrepid Axure hackers, I was inspired to put together a prototype that allows for dynamic JavaScript and CSS injection from within the prototype. Instead of using AxShare plugins and includes, you can just drop in functions written with AxQuery, jQuery, and JavaScript that you can immediately call with your widgets and events. No extra files, no need for AxShare, and you don’t even have to edit a single generated file.
It looks like this:
All you do is drag the “JavaScript Engine” master into a page, hide the “JAVASCRIPT ENGINE” widget OnPageLoad, and edit the text in the shape with whatever code you want. You can then use Axure events to call any JavaScript functions you’ve written with Open Link, using “javascript:functionname();”.
As a bonus, I added CSS injection as well. The attached .rp has both a page of examples (including live phone number validation via regular expression) and a base template that you can duplicate and modify for your own use.
Feedback is welcomed!
UPDATE: Modified the JavaScript injection so “<” and “>” don’t break the code. Using .html() and other code injections should now be much easier. Also, starting the engine now only requires that you hide the widget “JAVASCRIPT ENGINE” in OnPageLoad.
ANOTHER 1.02: I’ve attached the entire thing as an Axure Library as well. Just add the library, then drag the “Javascript Engine” widget onto any page you want JS on. Hide the JAVASCRIPT ENGINE widget and you’re good to go!
UPDATE 1.03:
CSS can be auto-applied to widgets now. Make sure “Apply on load” in the style panel is checked and any widgets with classes in the name, e.g. “email field .highlight” will have the appropriate classes added on load. (Note: this means your widgets will have weird names, which makes AxQuery a little more unwieldy - if anyone knows a way to update widget names from AxQuery, I’d love to hear it so I can cut the class names out after it generates)
The library now includes a “Hidden engine” widget that is included in a 40x40 hidden DP so you can add it to your page without cluttering the view as much.
AxQuery and JavaScript 1.03.rp (91.8 KB)
AxureJS 1.03.rplib (87.7 KB)