Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

[Added] Use custom options to create a select2 object

Information about updates, news, Code Library
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

[Added] Use custom options to create a select2 object

Unread post by admin »

To create a select2 object with custom options, declare a function nuOnSetSelect2Options() in BE (PHP):

Code: Select all

$s = "

function nuOnSetSelect2Options(i) {

    return {
        placeholder: 'This is my placeholder',
        allowClear: true
    };

}

";

nuAddJavascript($s, true);

Note that the 2nd parameter of nuAddJavascript() is set to true to add the JS before the form/objects are created.

Here is a list of all the Select2 configuration options:

https://select2.org/configuration/options-api
Post Reply