views:

20

answers:

1

Hi

I have a livesearch and it uses an unordered list, like this:

<input id="search"/>
<ul id="list>
  <li>1</li>
  <li>2</li>
</ul>

Now I have the liveSearch function put on these items:

$('#search').liveUpdate('#list').focus();

At first I was testing with a static list, it worked like charm. Now I'm trying to load it asynchronous with the following statements:

//$('#list').load('/search/organization');
//$('#list').load('/search/person');
//$('#list').load('/search/debitor');
$('#list').load('/search/accountname');

The data is loaded as normal but now the search isn't working anymore. I'm not that used to using ajax so maybe this is a common problem?

Thanks in advance,

EDIT:

When I add this line of code, or alert it somewhere else it returns 1. There is always only one element in the ul.

$('#list').load('/search/organization');
var test = jQuery('#list');
alert(test.length);

Still no sollution found.

A: 

The plugin actually has a cache of the <li> elements that are being replaced, so you need to "unbind" the former handler and re-bind it again, like this:

$('#list').load('/search/accountname', function() {
  $('#search').unbind('keyup').liveUpdate('#list');
});

Since the plugin is rigged up to the .keyup() handler, you're just unbinding that and adding a new one. To really clean up, you could add a .parents('form').unbind('submit'), but if you had any other submit handlers on the <form>, that'd be a bad idea :)

Nick Craver
Thanks, but i'm getting a liveUpdate is not a function error.Variations aren't working either.
baklap
@baklap - Are you by chance including jQuery again in the page, or in the loaded page? that'll wipe out any plugins when it happens.
Nick Craver
@NickCraver - No I put it on the end of the .js loading queue.I do have to add:$('#search').liveUpdate('#list').focus();on the end to rebind it, isn't it?Still not working though.
baklap
@baklap - Nope....if you're getting `is not a function` then the plugin's getting erased...if you have a link I can take a quick look.
Nick Craver
Would like but it runs locally on a development server.Maybe it's because the liveUpdate is bound after the loading. Let me have a look.edit: nup, still the same error
baklap
@baklap - What result do you get when you type `$.fn.liveUpdate` in the console?
Nick Craver
@NickCraver >>> $.fn.liveUpdate();TypeError: $.fn.liveUpdate is not a function { message="$.fn.liveUpdate is not a function", more...}Very very strange...
baklap
Hmm ghmm blegh, I think I found it.Im making use of the Zend Framework with ZFDebug included. The error occurs with ZFDebug. Man what a waste of time.
baklap
Hmm it doens't output the error anymore. It aint working either.
baklap
@baklap - Can you elaborate, or have a page you can provide a link to?
Nick Craver
@Nick Craver. I;VE GOT IT! Finally.I was loading an <ul> in another <ul> instead of a <li>.Stupid small problem in combination with a conflict with ZFDebug. Hmm thanks for your help!
baklap
@baklap - Welcome, glad you got it resolved :)
Nick Craver