Open avados opened 8 years ago
Is it possible to do it with "data" option?
I have the same issue. Is there any function that can reload data? @pbauerochse
Right now there is no way to reload the data but I will try to implement it as soon as I find time for it (unfortunately right now I'm quite busy so I don't find much time for SOL). If any of you guys know yourself around jquery plugins feel free to file a pull request if you implemented it yourself.
I am able to refresh and change control settings. In "$.fn.searchableOptionList = function (options) {" method you will find "if ($alreadyInitializedSol) { result.push($alreadyInitializedSol); } " code that should be changed as below:
if ($alreadyInitializedSol) {
$alreadyInitializedSol.$container.html('');
var newSol = new SearchableOptionList($this, options);
result.push(newSol);
setTimeout(function () {
newSol.init();
}, 0);
}
@subba4545: Your solution did help me to get out of a situation where i was stuck in hitting my head to how to reload the data when using ajax calls. Many thanks for your solution, however the exact solution didn't work for me to refresh the data in sol. below are the changes that i added further to achieve the goal. this line
$alreadyInitializedSol.$container.html('')
didn't work for me, instead i achieved it via this
$this.siblings('.sol-container').empty().remove();
This achieved the goal to show updated sol but underneath select element had items appended to it. So clear the previous options and re-append new options to original element was also needed and is done in
loopFunction
as below ` /if data is from some non static source then remove original element options if any and then re-append via each solitem/
if (this.config.data)
this.$originalElement.empty();
and inside while loop
if (this.config.data)
$('<option />')
.attr('text', item.label.trim())
.attr('value', item.value.trim())
.html(item.label.trim())
.appendTo(this.$originalElement);
and
if (this.config.data)
$('<optgroup />')
.attr('label', item.label.trim())
.html(item.label.trim())
.appendTo(this.$originalElement);
@pbauerochse: Many thanks for a wonderful plugin, as i am new to GitHub, didn't know how to contribute via pull request this change to the plugin. So kindly if you get some time for this plugin, update it to save many others time.
@Usman-Majeed Thank you very much, your above solution perfectly working for me. :1st_place_medal:
once the data is loaded, is it possible to refresh it? i have several object in my app, and when clicking on one of them, i am displaying the previously selected values for this object. But when clicking on another object, selected values should change too, i didn't find another way beside remove the div containing sol, and then adding it again.