Javascript Execution in optional Block Jelly

478 views Asked by At

Is there any way to execute Javascript in an optional block of Jelly?

Use Case: I want to update another section on the page each time there is a toggle on the checkbox.

1

There are 1 answers

0
nilesh virkar On

Yes, you can execute javascript in Jelly script, you need to call javascript from <script> tag, e.g

<script type="text/javascript" >
alert("Hello World!");

you need to fetch id of the section and refresh it on js event or simply use jelly core tags <j:core> with html basic input tags

For refreshing option block or any other section you may need to do something,

<f:checkbox name="${attrs.name}" class="optional-block-control block-control" onclick="javascript:updateOptionalBlock(this,true)"
                  negative="${attrs.negative}" checked="${attrs.checked}" field="${attrs.field}" title="${title}" /

Also for advanced execution, you can check <j:choose>, <j:when> like tags and bind that with your backend code and refresh dynamically.

It is better to check some advance GitHub code :) https://github.com/jenkinsci...