How to set the selectize options dynamically in selectize.js input?How do you remove all the options of a select box and then add one option and select it with jQuery?What is the best way to add options to a select from as a JS object with jQuery?How can I merge properties of two JavaScript objects dynamically?How can I know which radio button is selected via jQuery?Adding options to a <select> using jQuery?How can I select an element with multiple classes in jQuery?How can I select an element by name with jQuery?How do I set/unset a cookie with jQuery?jQuery Get Selected Option From DropdownSet select option 'selected', by value
What is the intuitive meaning of having a linear relationship between the logs of two variables?
Fine Tuning of the Universe
For a non-Jew, is there a punishment for not observing the 7 Noahide Laws?
Tiptoe or tiphoof? Adjusting words to better fit fantasy races
What Brexit proposals are on the table in the indicative votes on the 27th of March 2019?
How does buying out courses with grant money work?
Where does the Z80 processor start executing from?
Increase performance creating Mandelbrot set in python
Was Spock the First Vulcan in Starfleet?
How to Reset Passwords on Multiple Websites Easily?
Is this apparent Class Action settlement a spam message?
Why didn't Theresa May consult with Parliament before negotiating a deal with the EU?
How do we know the LHC results are robust?
Why not increase contact surface when reentering the atmosphere?
What is paid subscription needed for in Mortal Kombat 11?
How do I find the solutions of the following equation?
Sequence of Tenses: Translating the subjunctive
How to draw lines on a tikz-cd diagram
How to check is there any negative term in a large list?
Detecting if an element is found inside a container
Opposite of a diet
Did Dumbledore lie to Harry about how long he had James Potter's invisibility cloak when he was examining it? If so, why?
How easy is it to start Magic from scratch?
Unreliable Magic - Is it worth it?
How to set the selectize options dynamically in selectize.js input?
How do you remove all the options of a select box and then add one option and select it with jQuery?What is the best way to add options to a select from as a JS object with jQuery?How can I merge properties of two JavaScript objects dynamically?How can I know which radio button is selected via jQuery?Adding options to a <select> using jQuery?How can I select an element with multiple classes in jQuery?How can I select an element by name with jQuery?How do I set/unset a cookie with jQuery?jQuery Get Selected Option From DropdownSet select option 'selected', by value
I have a table inside a form which have a selectize input field. I have to populate the selected value based upon some condition. The data is coming in table in chunks first 10 records are showing correct selected value but when i append next 10 record in table selected values are not coming there is a show more button that append each time 10 records in table.
Below is my code:
This function set the options in the field. I use offset here to set the selected value from after next append row means offset value is 0 first time 10 second time and so on.
function initializeSelectizeChainage(options, offset)
var $select_chainage = $('.select-tools-chainage').selectize(
maxItems: 1,
valueField: 'id',
labelField: 'chainage_name',
searchField: 'chainage_name',
options: options,
highlight: true,
openOnFocus: true,
create: false,
dropdownParent: 'body',
/*selectOnTab:true,*/
load: function(query, callback)
if (!query.length) return callback();
$.ajax(
url: '<?php echo SITEURL; ?>/Requistion/selectChainage',
type: 'post',
dataType: 'json',
data:
name: query,
,
error: function()
callback();
,
success: function(res)
callback(res);
);
)
var chainage_ids = arrayColumn(options, 'id');
var rows = $(".table tbody tr");
var valueToBeSet;
for (var i = offset; i < rows.length; i++)
if ($.inArray($(rows[i]).find('.chainage').val(), chainage_ids) != -1)
valueToBeSet = options[$.inArray($(rows[i]).find('.chainage').val(), chainage_ids)];
$select_chainage[i].selectize.setValue(valueToBeSet.id, true);
I have used arrayColumn() function here to get the chainage_ids for each row for my logic to set the option right. Below the function:
function arrayColumn(array, columnName)
return array.map(function(value, index)
return value[columnName];
)
Now first time it works correct but from next time it will not setting the default value in selectixe text field.
Any help is appreciated.Thanks.
javascript jquery selectize.js
add a comment |
I have a table inside a form which have a selectize input field. I have to populate the selected value based upon some condition. The data is coming in table in chunks first 10 records are showing correct selected value but when i append next 10 record in table selected values are not coming there is a show more button that append each time 10 records in table.
Below is my code:
This function set the options in the field. I use offset here to set the selected value from after next append row means offset value is 0 first time 10 second time and so on.
function initializeSelectizeChainage(options, offset)
var $select_chainage = $('.select-tools-chainage').selectize(
maxItems: 1,
valueField: 'id',
labelField: 'chainage_name',
searchField: 'chainage_name',
options: options,
highlight: true,
openOnFocus: true,
create: false,
dropdownParent: 'body',
/*selectOnTab:true,*/
load: function(query, callback)
if (!query.length) return callback();
$.ajax(
url: '<?php echo SITEURL; ?>/Requistion/selectChainage',
type: 'post',
dataType: 'json',
data:
name: query,
,
error: function()
callback();
,
success: function(res)
callback(res);
);
)
var chainage_ids = arrayColumn(options, 'id');
var rows = $(".table tbody tr");
var valueToBeSet;
for (var i = offset; i < rows.length; i++)
if ($.inArray($(rows[i]).find('.chainage').val(), chainage_ids) != -1)
valueToBeSet = options[$.inArray($(rows[i]).find('.chainage').val(), chainage_ids)];
$select_chainage[i].selectize.setValue(valueToBeSet.id, true);
I have used arrayColumn() function here to get the chainage_ids for each row for my logic to set the option right. Below the function:
function arrayColumn(array, columnName)
return array.map(function(value, index)
return value[columnName];
)
Now first time it works correct but from next time it will not setting the default value in selectixe text field.
Any help is appreciated.Thanks.
javascript jquery selectize.js
No error in console ,actually each time I am running this method first time in document.ready and after that click on show more button that append 10 more records in tbody.
– Jeevan
Mar 7 at 16:02
add a comment |
I have a table inside a form which have a selectize input field. I have to populate the selected value based upon some condition. The data is coming in table in chunks first 10 records are showing correct selected value but when i append next 10 record in table selected values are not coming there is a show more button that append each time 10 records in table.
Below is my code:
This function set the options in the field. I use offset here to set the selected value from after next append row means offset value is 0 first time 10 second time and so on.
function initializeSelectizeChainage(options, offset)
var $select_chainage = $('.select-tools-chainage').selectize(
maxItems: 1,
valueField: 'id',
labelField: 'chainage_name',
searchField: 'chainage_name',
options: options,
highlight: true,
openOnFocus: true,
create: false,
dropdownParent: 'body',
/*selectOnTab:true,*/
load: function(query, callback)
if (!query.length) return callback();
$.ajax(
url: '<?php echo SITEURL; ?>/Requistion/selectChainage',
type: 'post',
dataType: 'json',
data:
name: query,
,
error: function()
callback();
,
success: function(res)
callback(res);
);
)
var chainage_ids = arrayColumn(options, 'id');
var rows = $(".table tbody tr");
var valueToBeSet;
for (var i = offset; i < rows.length; i++)
if ($.inArray($(rows[i]).find('.chainage').val(), chainage_ids) != -1)
valueToBeSet = options[$.inArray($(rows[i]).find('.chainage').val(), chainage_ids)];
$select_chainage[i].selectize.setValue(valueToBeSet.id, true);
I have used arrayColumn() function here to get the chainage_ids for each row for my logic to set the option right. Below the function:
function arrayColumn(array, columnName)
return array.map(function(value, index)
return value[columnName];
)
Now first time it works correct but from next time it will not setting the default value in selectixe text field.
Any help is appreciated.Thanks.
javascript jquery selectize.js
I have a table inside a form which have a selectize input field. I have to populate the selected value based upon some condition. The data is coming in table in chunks first 10 records are showing correct selected value but when i append next 10 record in table selected values are not coming there is a show more button that append each time 10 records in table.
Below is my code:
This function set the options in the field. I use offset here to set the selected value from after next append row means offset value is 0 first time 10 second time and so on.
function initializeSelectizeChainage(options, offset)
var $select_chainage = $('.select-tools-chainage').selectize(
maxItems: 1,
valueField: 'id',
labelField: 'chainage_name',
searchField: 'chainage_name',
options: options,
highlight: true,
openOnFocus: true,
create: false,
dropdownParent: 'body',
/*selectOnTab:true,*/
load: function(query, callback)
if (!query.length) return callback();
$.ajax(
url: '<?php echo SITEURL; ?>/Requistion/selectChainage',
type: 'post',
dataType: 'json',
data:
name: query,
,
error: function()
callback();
,
success: function(res)
callback(res);
);
)
var chainage_ids = arrayColumn(options, 'id');
var rows = $(".table tbody tr");
var valueToBeSet;
for (var i = offset; i < rows.length; i++)
if ($.inArray($(rows[i]).find('.chainage').val(), chainage_ids) != -1)
valueToBeSet = options[$.inArray($(rows[i]).find('.chainage').val(), chainage_ids)];
$select_chainage[i].selectize.setValue(valueToBeSet.id, true);
I have used arrayColumn() function here to get the chainage_ids for each row for my logic to set the option right. Below the function:
function arrayColumn(array, columnName)
return array.map(function(value, index)
return value[columnName];
)
Now first time it works correct but from next time it will not setting the default value in selectixe text field.
Any help is appreciated.Thanks.
javascript jquery selectize.js
javascript jquery selectize.js
edited Mar 7 at 13:09
drp
13110
13110
asked Mar 7 at 12:53
JeevanJeevan
379
379
No error in console ,actually each time I am running this method first time in document.ready and after that click on show more button that append 10 more records in tbody.
– Jeevan
Mar 7 at 16:02
add a comment |
No error in console ,actually each time I am running this method first time in document.ready and after that click on show more button that append 10 more records in tbody.
– Jeevan
Mar 7 at 16:02
No error in console ,actually each time I am running this method first time in document.ready and after that click on show more button that append 10 more records in tbody.
– Jeevan
Mar 7 at 16:02
No error in console ,actually each time I am running this method first time in document.ready and after that click on show more button that append 10 more records in tbody.
– Jeevan
Mar 7 at 16:02
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55044284%2fhow-to-set-the-selectize-options-dynamically-in-selectize-js-input%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55044284%2fhow-to-set-the-selectize-options-dynamically-in-selectize-js-input%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
No error in console ,actually each time I am running this method first time in document.ready and after that click on show more button that append 10 more records in tbody.
– Jeevan
Mar 7 at 16:02