Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
edwin
Master II
Master II

integrating Select2 into Qlik Sense extensions

Hi,
i havent come across anyone using Select2 in their extensions.  theres a look and feel we wanted to be consistent that we need to create a select2 extension.

i cant appear to be able to integrate it, im just starting out and a simple load isnt invoking select2.  here is part of my code:

 

require.config({packages: [{name: 'select2lib',main: 'select2lib'}],
                paths: {'select2lib': 'https://cdnjs.cloudflare.com'}
});

define( [ "qlik", 'jquery',
	"./Properties",
	"select2lib/ajax/libs/select2/4.0.0/js/select2.min",
	'text!./select2.min.css',
	'text!./Style.css',
	
],
function ( qlik, $, 
	properties, 
	select2min,
	select2mincss,
	cssContent) {

 

this is how i invoke it:

 

$(containerID).select2({
    templateResult: function (data) {
      var $res = $('<span></span>');
      var $check = $('<input type="checkbox" />');
      
      $res.text(data.text);
      
      if (data.element) {
        $res.prepend($check);
        $check.prop('checked', data.element.selected);
      }
  
      return $res;
    }
});

 

i dont encounter any errors but when i inspect the page, it doesnt look like select2 was even being called.

hoping someone can help

thanks,
edwin

*edited the invoke to select2 (was playing around with it)

 

Labels (2)
1 Solution

Accepted Solutions
alex_colombo
Employee
Employee

Hi @edwin are you loading select2 from internet?
I usually load external js code directly in my project folder in this way

define(["qlik", "./properties", "./plotly-latest.min", "text!./style.css", "./locale/plotly-locale-it" 
],


	function (qlik, properties, Plotly, cssContent, localeIt) {

 

And this is my project structure

alex_colombo_0-1679906419314.png

Please check if you are pointing to the correct folder and try to remove require.config from beginning of your code.

View solution in original post

3 Replies
alex_colombo
Employee
Employee

Hi @edwin are you loading select2 from internet?
I usually load external js code directly in my project folder in this way

define(["qlik", "./properties", "./plotly-latest.min", "text!./style.css", "./locale/plotly-locale-it" 
],


	function (qlik, properties, Plotly, cssContent, localeIt) {

 

And this is my project structure

alex_colombo_0-1679906419314.png

Please check if you are pointing to the correct folder and try to remove require.config from beginning of your code.

edwin
Master II
Master II
Author

Hi Alex

thanks for the response.  ive already done a couple scenarios.  ive done one where i copied the JS file locally - for that situation i didnt use the require.

ill try once more and see  

edwin
Master II
Master II
Author

Hi,

i thought i did this already but i guess i havent and it did work.

thanks Alex,

edwin