[jQuery] Re: append div trouble [SOLVED]

2008-05-20 Thread kws452

ok i am trying to do the same thing you are doing, with no success.
Only difference is I'm using suckerfish for my navigation menus across
the top. The navigation is loaded via an external file, with things
like add, search, etc as my main menus.  The drop down menus set
up nicely, and I have js set up so that when a user selects a menu
item, different content is loaded into a div in the middle of the
page depending on what they click on. I just switched to livequery, so
my js is:

$(document).ready(function() {
  ('#home')
 .livequery('click', (function() {
  $('#content').load('index.php')
  return false;
 })

('#search')
 .livequery('click', (function() {
  $('#content').load('search.php')
  return false;
 })
);

My goal is for the user to always be able to click on the navigation
menu and start over or load new content.  So if the user chooses
search, search.php is loaded, which is a form.  They enter the
users company name and press submit.  Data is shown in the div in
the middle of the page.  Now I want the user to be able to click on
the navigation menu again and search on something different.

This does not work - it seems like once data is displayed in the
#content div, the navigation menu doesn't work.  I guess I thought
this was what livequery would do for me.  Does anyone have time to
look at this and see what I am doing wrong?


[jQuery] Re: append div trouble [SOLVED]

2008-05-07 Thread flipthekid

That was it Richard. thanks.
I ended up using livequery to rebind the click handler

$('#navigation  [EMAIL PROTECTED]#]').livequery('click', function(event) {

$('#navigation').empty().append(hex); .
.

that way the append content acts like it used to.

you can see it in action here -- http://studio4nine.com/html2/index.html
the whole idea was to be able to de link the link you clicked on.
a friend of mine helped with setting that up based on the hash in the
URL.
that way you can deep link the site, since it's only 1 html page.

kind of a goofy experiment, but i think it worked out cool.

thanks again.
gary.


[jQuery] Re: append div trouble

2008-05-06 Thread Richard D. Worth
When you do

$('#navigation').empty().append(hex);

you're adding brand spanking new links to the DOM from straight html. They
have no special click-handler applied. Maybe hide them instead of removing
them? Then just show to restore? Otherwise, hopefully this will be of some
help:

http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_stop_working_after_an_Ajax_request.3F

- Richard

Richard D. Worth
http://rdworth.org/

On Tue, May 6, 2008 at 5:01 PM, flipthekid [EMAIL PROTECTED] wrote:


 hey folks,
 brand new here. been fiddling with jquery for a little bit now, but
 this one has me stumped.

 the goal is to de-link the links on a navigation system depending on
 what you've clicked on.
 but i need a restore function which i'm trying to do with append

 the functions work fine without the append, but then i can't restore
 the links i've taken off.
 and after i do the append the html looks fine, but it doesn't seem to
 be part of the DOM anymore.
 since it won't respond to the functions anymore.

 i've tried so many things and got no where.
 i believe it to be NOT appending to the DOM

 but again i'm new to the more complex stuff.

 thanks in advance for any help.
 gary.


 [code DOM ready]

 // get all the html in the navigation div
 var hex = $(#navigation).clone().html();

 // my trigger
 // all links with an anchor tag inside of navigation
 $('#navigation  [EMAIL PROTECTED]#]').click(function() {

 // set a variable to what i clicked on
 var clickedMe = $(this);

 // restoring state of navigation div
 $('#navigation').empty().append(hex);

 // here i do all my style changes using the clickedMe variable
 // including replacing the link i clicked on with just text
 // omitted for clarity

 });

 [/code]