Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

setValue within onInitialize? #2040

Unanswered
killnine asked this question in Q&A
Discussion options

Hi all,

I am using selectize for a report and I save off the input entries to local storage so that when users return to the page their query criteria is still populated. However, I am not sure how to load the selection from onInitialize.

<script type="text/javascript">
 !function (l) {
 "use strict";
 function e() { }
 e.prototype.initSelectize = function () {
 l("#selectize-skus").selectize({
 plugins: ["remove_button"],
 persist: !1,
 createOnBlur: !0,
 create: !0,
 onChange: function (value) {
 Lockr.set('skus', value);
 },
 onInitialize: function () {
 var skus = Lockr.get('skus');
 if (skus)
 {
 this.setValue(skus);
 }
 }
 });
 }, e.prototype.init = function () {
 this.initSelectize() },
 l.BillListSelectize = new e, l.BillListSelectize.Constructor = e
 }(window.jQuery), function () {
 "use strict";
 window.jQuery.BillListSelectize.init();
 }();
 </script>

You can see that when onChange fires, I save the selections to storage. Then onInitialize should pull those values back from storage and assign, if they exist. However, this doesn't seem to be working and I'm not sure why. I've seen others reference setValue but typically out of the context of the initializer.

FYI: My page actually has multiple selectize inputs but I've stripped those out for clarity.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /