Minimizing a custom widget

11 views
Skip to first unread message

Joachim Nilsson

unread,
Nov 2, 2015, 6:53:47 AM11/2/15
to Jenkins Developers
Hi
How do I minimize a custom widget?
I have added an index.jelly page with content:

<?xml version="1.0" encoding="utf-8"?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:l="/lib/layout">
<l:pane width="2" title="Get a number">
<tr>
  <td align="left">Number</td>
  <td class="my-count" align="right">${it.number}</td>
</tr>
</l:pane>
<script>
  var widget = <st:bind value="${it}"/>;
  var upDateInterval = 1000;
  window.setInterval(function() {
    widget.getNumber(function(t) {
      document.getElementsByClassName('my-count')[0].textContent = t.responseObject();
    })
  },upDateInterval);

</script>
</j:jelly>


and my class:

@Extension(ordinal = 500)
public class MyWidget extends Widget {
    private int x = 0;

    @JavaScriptMethod
    public int getNumber() {
        x++;
        return x;
    }
}


When I press the minimize icon, nothing happens. Is there some code to add for this feature to work?

Regards,
Joachim

Joachim Nilsson

unread,
Nov 25, 2015, 6:54:46 AM11/25/15
to Jenkins Developers
Thanks mattiasclaesson for the input. It was correct: adding an ID to the jelly pane was enough to be able to minimize it.

<l:pane width="2" title="Get a number" id="MyUniqueWidgetId">
Reply all
Reply to author
Forward
0 new messages