Jump to content

replacing content in a div


Shadowing

Recommended Posts

Hey guys im having a wierd issue I have a ajax working menu that when you click on each item in the menu a div pops up. I'm trying to have each menu item use the same div. So this is pretty much what each menu item has. what happends is when I click on "li.planets" the div appears with its content and then I click "#close" and it clears the div makes it blank but for some reason when i click on "li.planets" again to show the div its blank instead of reloading the content. for my understanding using html should replace content every time right?

 $("li.planets").click(function(event) {	     $("div.child_window").show(0);			 	 $("a#close").click(function(event) {				$("div.child_window").hide(0);		$('div.child_window_content').html("");		$('div.child_window_menu').html("");	 }); });        $("div.child_option1").click(function(event) {     $.ajax({		      url: "ajax/menu_planets.php?functions=planets_owned",		      type: 'POST',		      	success: function(response) {		$('div.child_window_content').html(response.display);		}  }); });

  • Like 1
Link to comment
Share on other sites

It's not going to auto-run the click function, but you should move the definition of that outside of the click handler for the other item. The way it is now, it adds another click event to the close button each time the click on a menu item, so when they click close it may run that function 2 or 3 times depending on how many menu items they clicked on.

Link to comment
Share on other sites

thanks for the reply. I decided to just use seperate divs hehe. I have another question though that is driving me crazy. If i place a input field on the screen after page load. Do i need to use live or something in order to grab its value with

$('#production_tech').val()

Link to comment
Share on other sites

im adding the field from a huge php string thats gets turned into JSON then $('div.technology_return').html(response.display); I dont understand why is it that i have to use live for clickable on elements being placed on the page after page load? isnt the reason i have to use live is so i can read the id of the clickable or is it just something else it needs that using live does

Link to comment
Share on other sites

I dont know if this is the same issue as i was having several days back with replacing content but I just ran into a issue again but this time I know whats going on. will try to explain this with out pictures lets say i have a div with a border around it named <div class='content'></div>when I replace content using

$('div.content').html(response.display);

instead of it placing the content inside the border it places it under the border first i changed the back ground color to something i can see and i notice that the back ground color goes a away when using html(). so then i added a border and sure enough its not even placing content with in the div tag. going to look through the html for errors but atm i have no idea. Also if I try to change the color of text it works.so its like the content is in the div tag but back ground color and borders are not working with it which is bad cause its the reason why my overflow isnt working how I need it too cause its not pushing content down

Edited by Shadowing
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...