Here is your code reformatted:

jQuery(".big_search").keyup(function() {
  ajax('partial_search', ['big_search'], 'search_hint')
});
$('.button').button();
});

The call to .button() happens outside the .keyup() callback (unless that 
was a copy/paste error). Even inside, though, I don't think it will wait 
for the ajax call to complete. Instead, you might consider using the jQuery 
.load() or .ajax() functions directly, both of which take a callback (which 
executes after the ajax call completes). Or you could set up a separate 
.ajaxSuccess() event handler:

jQuery('.big_search').ajaxSuccess(function(e, xhr, settings) {
  if (settings.url == 'partial_search') {
    jQuery('.button').button();
  }
});

Anthony

On Thursday, August 9, 2012 6:24:38 PM UTC-4, Mike wrote:
>
> I guess this is really more of a jquery question but I figured there may 
> be some easier web2py builtin way to do this...
>
> I'm doing some custom auto completion on an input field and thought the 
> example from the book made more sense for my usage (as opposed to the built 
> in autocomplete widget). That part is working great:
>
> ** book example code:
>
> <form>
>
>  <input type="text" id="month" name="month" style="width: 250px" /><br />
>
>  <div style="position: absolute;" id="suggestions"
>
>       class="suggestions"></div>
>
> </form>
>
> <script>
>
> jQuery("#month").keyup(function(){
>
>       ajax('month_selector', ['month'], 'suggestions')});
>
> </script>
>
>
> Okay so the problem I'm having is that instead of Months like the example 
> above, I am returning divs with class of 'button' and using jquery ui to 
> try to turn those into buttons after they are loaded in. I'm having trouble 
> with the jquery syntax here. 
>
> right now I have:
>
> jQuery(".big_search").keyup(function(){
>
>       ajax('partial_search', ['big_search'], 'search_hint')});
>
> $('.button').button();
>
>  
>
> });
>
>
> The buttons flash for a second and quickly disappear. Can someone throw me 
> some pointers here or a better place to look?
>
> Thanks in Advance! 
>
>  
>  
>

-- 



Reply via email to