pbauerochse / searchable-option-list

a jquery plugin for a searchable optionlist
MIT License
79 stars 54 forks source link

Dynamic binding to SOL, based on multiple selection #62

Open tapan8 opened 6 years ago

tapan8 commented 6 years ago

Hi,

How can we dynamically bind SOL while getting the parameters values from the another SOL.

Which event should be called and where in jscript, while performing the ajax call?

Can we retain the selected values in the second SOL while appending/refreshing the SOL.

example: Need to bind the first SOL with Course and then bind the second SOL with subjects for the selected courses.

@Html.DropDownList("my-select", (IEnumerable)ViewBag.CourseList, htmlAttributes: new { multiple = "multiple" })

SOL.js // Refered https://github.com/pbauerochse/searchable-option-list/issues/51 $.fn.searchableOptionList = function (options) { var result = []; this.each(function () { var $this = $(this), $alreadyInitializedSol = $this.data(SearchableOptionList.prototype.DATA_KEY); if ($alreadyInitializedSol) { //result.push($alreadyInitializedSol); $alreadyInitializedSol.$container.html(''); var newSol = new SearchableOptionList($this, options);
result.push(newSol);
setTimeout(function () { newSol.init(); }, 0); } else { var newSol = new SearchableOptionList($this, options); result.push(newSol);

            setTimeout(function() {
                newSol.init();
            }, 0);
        }
    });

    if (result.length === 1) {
        return result[0];
    }

    return result;
};

Thanks Tapan tapan@skytesters.com