javascript - How to create External data-source in html5 -


in html5 input field has following format

 <input type='text', data-provide= "typeahead", data-items="4",  autocomplete="off",  data-source='["business , commercial laws",  "consumer laws", "criminal laws"]', name='userinputname',  placeholder='court of practice'> data </input> 

how create link above tag data-source not inline, external. want re-use data-source.

edit: using typeahead plugin in bootstrap. programming in node.js framework. can use

- var arrayvar = [ "this", "that", "here"]

 data-source='#{arrayvar}'  

but above converts array arrayvar string "this, that, here" not desired, data-source should array.

data attributes can retrived jquery.

$('[data-source']).each(function(){ // select elements data-source attribute     var $this = $(this), source = $this.data("source");      // update source     $this.data("source", sourcetoarray(source)); }); 

fitting framework might difficult, suggest choosing unused attribute, or making sure code fires before angularjs loaded.


Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -