-
How to initiate plugin from native |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
[UPDATE] v1.0.22 - This feature is supported in the plugin itself (more details) --- NOT RECOMMENDED --- It is not recommended to use native elements, to get the option's value and label to initiate the plugin. If there is any rare scenario, where you could initiate plugin only from native select, use the below helper function in your project to initiate plugin. function initVirtualSelectFromNativeSelect(id) {
var $ele = document.querySelector('#' + id);
var $options = $ele.querySelectorAll('option');
var options = [];
/** getting options */
$options.forEach(function ($option) {
options.push({
label: $option.innerHTML,
value: $option.value,
});
});
/** creating div element to initiate plugin and removing native element */
var $newEle = document.createElement('div');
$newEle.id = id;
$ele.parentNode.insertBefore($newEle, $ele.nextSibling);
$ele.remove();
/** initiating virtual select */
VirtualSelect.init({
ele: '#' + id,
options: options,
});
} |
Beta Was this translation helpful? Give feedback.
-
Is the required parameter supported? |
Beta Was this translation helpful? Give feedback.
-
This feature is supported in the plugin itself v1.0.22 (more details) |
Beta Was this translation helpful? Give feedback.
This feature is supported in the plugin itself v1.0.22 (more details)