In jquery jqgrid, Is there anyway to have dropdown delayed until chosen? In jquery jqgrid, Is there anyway to have dropdown delayed until chosen? ajax ajax

In jquery jqgrid, Is there anyway to have dropdown delayed until chosen?


Check this out:

Markup:

<select id="ddl">    <option value="-1">Select One</option></select>

jQuery:

$("body").delegate("#ddl", "focus",function(event){    //ajax call here, and then append items    $(this).append("<option value='1'>Option 1</option>");    $(this).append("<option value='2'>Option 2</option>");    $(this).append("<option value='3'>Option 3</option>");    $(this).append("<option value='4'>Option 4</option>");    $(this).append("<option value='5'>Option 5</option>");});

jsFiddle: http://jsfiddle.net/9asfG/


I think you can do it in server side also, in the code you can add an if-statement to check inside the $_POST["_search"], if this is true, then loop inside $_POST, find if the dropdown-search condition been post, if no, echo something blank or whatever to stop the code, if yes then continuing loading data from DB.

PS.: My personal opinion, maybe it's not a good idea to "delay" the result, cause user might don't know he need to select the dropdown first, it's not a good design from user experience point of view.