Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
156
rated 0 times [  159] [ 3]  / answers: 1 / hits: 26252  / 11 Years ago, wed, october 2, 2013, 12:00:00

I want to change placeholder of a dropdown created by selectize.js when the parent dropdown changes its selection to load the options of the dropdown whose placeholder to be changed. There is no method to do this in documentation.


More From » jquery

 Answers
23

Not sure if selectize keeps changing their code or if everyone else on this thread just whiffed but all of these answers seem to be wrong individually, but if you kind of combine the correct parts from each answer you wind up with this which works for me.



        var textHandler = function(name) {
return function() {
if(name == 'focus'){
jQuery(select#myid + .selectize-control).find(input:text).prop({placeholder: });
}
};
};
jQuery('#sf159_textsearchtextsearch').selectize({
closeAfterSelect: true,
hideSelected : true,
createOnBlur : true,
openOnFocus : true,
maxOptions : 10,
persist : true,
placeholder : Neighborhood, Street, School, Zip, MLS,
plugins : ['remove_button'],
valueField : 'id',
labelField : 'text',
searchField : 'value',
options : [],
create : false,
render : {
option: function (item, escape) {
//console.log(item);
var address = '';
var keyword = '';
var tx = item.text.split(',');
for (var i = 0, n = tx.length; i < n; i++) {
address += '<span class=span4>' + escape(tx[i]) + '</span>';
}
var template = '<div>' +
'<div class=row-fluid> ' + address + ' </div>' +
'</div>';
return template;
}
},
load : searchHandler,
onKeydown : keyHandler,
onDelete : deleteHandler,
onFocus : textHandler('focus'),
});

[#75275] Tuesday, October 1, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nestorjarettg

Total Points: 451
Total Questions: 108
Total Answers: 108

Location: Rwanda
Member since Thu, Feb 10, 2022
2 Years ago
;