$('#pageLeft').click(... looks for the element with that ID at the
time its run. If there's no match, it won't do anything. You need to
either add the event listeners after you change the element's ID, or
use event delegation. See the LiveQuery plug-in:
http://brandonaaron.net/docs/livequery/
- ricardo
On Dec 30, 1:39 pm, Chuk <[email protected]> wrote:
> Hi. I'm using CGIDEV2 with AJAX, JQuery, and JSON to page through
> search results (showing 100 at a time). For the paging, I have a
> beginning arrow, page left arrow, page right arrow, and an end arrow.
> When I am on the first page of results, the beginning and page left
> arrows have an id of "beginningDeactivated" and "pageLeftDeactivated"
> respectively. Once the page right arrow is clicked and thus taken to
> the second page, I use .attr to change the ids to "beginning" and
> "pageLeft". Then, I have the following waiting for a click on
> pageLeft.
>
> $('#pageLeft').click(function()
> {
> ...
>
> }
>
> However, if I click on the element with the id of "pageLeft," the
> event is not triggered. I've quadruple checked the id using firefox's
> firebug, and it is the exact same. Could it be that since the
> original id of this element was not "pageLeft" (instead, it was
> "pageLeftDeactivated"), the click function assigned to an element with
> the id "pageLeft" will never be triggered? Or is it just something
> else that I'm not thinking of? I will post code if I need to. I just
> didn't want to clutter things up.