Applying JavaScript and CSS on f:select

51 views
Skip to first unread message

Daniel Akua

unread,
May 10, 2021, 5:44:29 AM5/10/21
to Jenkins Developers
Hi all,
In my plugin I have a <f:select> element with the multiple attribute (multi-select) that is changing according to another field.
My problem is that I want to apply JavaScript and CSS to it to make it look better than the standard multi-select element.

it currently looks like this:
before.png

and I want it to look something like this:
after.PNG

I have the required JS and CSS files and it is working on a normal <select> element but not on <f:select>.

How do I apply JavaScript and CSS on <f:select>?
Is there some guide on how to do it?

Tips or links will be appreciated.

Ullrich Hafner

unread,
May 11, 2021, 3:48:59 PM5/11/21
to Jenkins Developers
Where do you want to use the element? In one of your views? Or in a job configuration page?

It is not required to use a f:select. Can’t you directly use the select or what is missing in that case (data binding?)?

Am 10.05.2021 um 11:37 schrieb Daniel Akua <danie...@experitest.com>:

Hi all,
In my plugin I have a <f:select> element with the multiple attribute (multi-select) that is changing according to another field.
My problem is that I want to apply JavaScript and CSS to it to make it look better than the standard multi-select element.

it currently looks like this:
<before.png>

and I want it to look something like this:
<after.PNG>

I have the required JS and CSS files and it is working on a normal <select> element but not on <f:select>.

How do I apply JavaScript and CSS on <f:select>?
Is there some guide on how to do it?

Tips or links will be appreciated.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/5c068520-dace-47bf-beff-5fbdc7392038n%40googlegroups.com.
<before.png><after.PNG>

Daniel Akua

unread,
May 12, 2021, 9:32:11 AM5/12/21
to Jenkins Developers
I am using this element in a "build environment" step in the configuration page.
And I must use the f:select because i need the binding.

Ullrich Hafner

unread,
May 12, 2021, 10:01:27 AM5/12/21
to Jenkins Developers
They only way I see is to copy the select.jelly (https://github.com/jenkinsci/jenkins/tree/master/core/src/main/resources/lib/form
into your plugin and try to rewrite it so that it works with your JS and CSS.

Tim Jacomb

unread,
May 12, 2021, 10:50:21 AM5/12/21
to Jenkins Developers
Why can't you apply CSS to it?

Are you missing attributes? Do you need to change the markup?

Better to avoid forking core widgets if you can as then plugins get out of sync when we make changes in core, and it was a real pain when we did the form modernisation work,
and any plugins that fork the widgets will look inconsistent if/when there's follow up work

Daniel Akua

unread,
May 13, 2021, 2:56:23 AM5/13/21
to Jenkins Developers
It's not just CSS, it's JavaScript as well. the element ignores it.
If i add id to f:select, it is removed in the html. if i use the auto generated name (_.XYZ) i can find the element and apply the changes but then i lose the binding.

I need to find a way to have both the binding and the pretty look

Gavin Mogan

unread,
May 13, 2021, 11:02:56 PM5/13/21
to Jenkins Developers
I think you need to give concrete examples (I've gotten in the habit of saying vague questions give vague answers)

Can you list the things you've tried. What did happen? and what you wanted to happen instead?

Gavin

Björn Pedersen

unread,
May 14, 2021, 3:32:03 AM5/14/21
to Jenkins Developers
From his examples I guess he wants somethig like  a choosen.js multiselect for a mulit-choice lists like  in extend-choice plugin.

Maybe take a look at 
https://plugins.jenkins.io/chosen/ (although rather antique...)

Björn

Ullrich Hafner

unread,
May 14, 2021, 8:56:04 AM5/14/21
to Jenkins Developers
A more modern widget is available as 

It is currently only available on the client side but it shouldn’t be hard to add support for the Jenkins form concept so that it can be used in server side UI code. 

Better to avoid forking core widgets if you can as then plugins get out of sync when we make changes in core, and it was a real pain when we did the form modernisation work,
and any plugins that fork the widgets will look inconsistent if/when there's follow up work

Yes, this is something you need to keep in mind. If you use your own widgets you will not get support if something changes in core. 

Daniel Akua

unread,
May 18, 2021, 5:18:00 AM5/18/21
to Jenkins Developers
i'll check if select2 and chosen have the pretty multi-select and the data binding that i need and update this thread
Reply all
Reply to author
Forward
0 new messages