I'm trying to put some simple javascript (create a pulldown that goes to defined webpage when selected). I'll post the question here, then give details.
For a simple html page, I'm fine getting it to work; however, in Plone, it dispalys but the actions don't work. Based on my research, it looks like for Plone it is not as simple as pasting JS into the raw HTML.
i am using Plone 5 with Embed Portlet because it allows me to add html.
when I add this JS:
-------Choose a Selection-------
Disbursements
Start Booster
======================
however, the action doesn't work (doesn't go to website when selected.)
I found various helpful sites:
So, am I correct in that one or both of these sites shows how JS is added and simply pasting as part of raw HTML won't get it done.
Thanks for pointer. If it is (for me) as complicated as above, that will tell me I can either use simple HTML hyperlink from the portlet or hire a programmer if I want JS.
Note: I just noted that above the Block where code is added in the embed Portlet, is the following text:
"HTML Code to embed The html snippet you want to use. It can be iframe, javascript, html"
So, should JS work here?
You dont say what console output you get after pasting js in the embed portlet. I think it should work as it is meant to bypass plone security if its the one I think. If I'm wrong then it is safehtml stripping out js and this js for security reasons.
Either way its really not a nice way of doing it.
Better to follow the tutorial to get a js file included in your page and then use some jquery onload to attach the behaviour to your select by Id. You can also add include a js file in your theme just via the theme editor the manifest. None of that zcml needed
@hvelarde thanks for the suggestion. I tried this in Plone 5. I instlled as described, and the installed/activated the product. all went fine.
Then I tired to add it to a portlet and got the "Modal" error. Here is the error details.
Traceback (innermost last):
Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module plone.app.portlets.browser.formhelper, line 59, in call
Module z3c.form.form, line 233, in call
Module plone.z3cform.fieldsets.extensible, line 58, in update
Module plone.autoform.form, line 33, in updateFields
Module plone.autoform.base, line 54, in updateFieldsFromSchemata
Module plone.autoform.form, line 22, in schema
NotImplementedError: The class deriving from AutoExtensibleForm must have a 'schema' property