Select data from empty and in span
hello .. i use a Ajax file to populate a jquery pulldown.
everything works perfect .. but i can ONLY select a item if i click beside the text (outside the span)
does anyone know how i can change the .live to have it run if clicked on the full div id=results
script:
- $(document).ready(function() {
- $(".search").keyup(function()
- {
- var searchid = $(this).val();
- var dataString = 'search='+ searchid;
- if(searchid!='')
- {
- $.ajax({
- type: "POST",
- url: "<?=$Site['paths']['url']?>lib/ajax/locationinlinesearch.php?country=<?=$basecountry?>&bplace=" + document.getElementById("bplace").value,
- data: dataString,
- cache: false,
- success: function(html)
- {
- $("#result").html(html).show();
- }
- });
- }return false;
- });
-
- jQuery("#result").live("click",function(e){
- var $clicked = $(e.target);
- var $name = $clicked.find('.name').html();
- var decoded = $("<div/>").html($name).text();
- $('#searchid').val(decoded);
- jQuery("#result").fadeOut();
- });
- $('#searchid').click(function(){
- jQuery("#result").fadeIn();
- });
- });
html (with ajax data published already)
- <form method="post"><br>
- <input class="search" id="searchid" style="font-size:1.0em; margin-top:0px; height:24px; border:1px solid #c2c2c2;" type="text" name="utown" size="32" autocomplete="off"><br><br> <input style="margin-left:0px;" id="tastesbutton" name="save" value="Save Changes" type="submit">
-
- <div id="result" style="display: block;">
- <!-- data provided via ajax -->
- <div class="show" align="left"><span class="name">BANGKOK</span> <small>( Bangkok )</small><br></div>
- <div class="show" align="left"><span class="name">Lat Krabang</span> <small>( Bangkok )</small><br></div>
- <!-- END data provided via ajax -->
- </div>
- </form>