javascript - How to set selected to option using ddSlick after postback? -


i need use image drop-down list http://designwithpc.com/plugins/ddslick trying set "selected" option after postback, infinite loop of postbacks. here code:

<form id="form1"> <select id="localeid" name="localeid"></select> </form>  <script type="text/javascript">         //dropdown plugin data         var dddata = [             {                 text: "english",                 value: "en",                 selected: false,                 description: "english",                 imagesrc: "/assets/img/flags-icons/en-flag.png"             },             {                 text: "portuguese",                 value: "pt",                 selected: false,                 description: "portuguese",                 imagesrc: "/assets/img/flags-icons/pt-flag.png"             },             {                 text: "russian",                 value: "ru",                 selected: false,                 description: "russian",                 imagesrc: "/assets/img/flags-icons/ru-flag.png"             },             {                 text: "spanish",                 value: "es",                 selected: false,                 description: "spanish",                 imagesrc: "/assets/img/flags-icons/es-flag.png"             }         ];          $('#localeid').ddslick({             data: dddata,             defaultselectedindex: 3,             onselected: function (data) {                 if (data.selectedindex > 0) {                     $('#hidcflag').val(data.selecteddata.value);                     $.cookie('lang', document.getelementbyid("hidcflag").value, { expires: 365 });                     form1.submit();                 }              }         });     </script> 

could please me solve it?

you may use plugin's select method

$('#demosetselected').ddslick('select', {index: }); 

to select particular index.

as per ddslick demo#4 on website(http://designwithpc.com/plugins/ddslick#demo)


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -