ColdEdge Posted January 31, 2011 Share Posted January 31, 2011 Hello, I am wondering how would I be able to load different pages with use of #!/web or #!/images ect Link to comment Share on other sites More sharing options...
justsomeguy Posted January 31, 2011 Share Posted January 31, 2011 What do you mean? What is "#!/web"? Link to comment Share on other sites More sharing options...
ColdEdge Posted February 1, 2011 Author Share Posted February 1, 2011 Hey JustsomeguyOk here is the site I am working on http://otaku-plus.com/as you can see in the top navigation there are bunch of links what I want to do is when user clisk images the link point to http://otaku-plus.com/#!/images but since this will be an ajax call via jQuery the search filed will say what images you would like to search for? and it will have dif character/color. So basically when that is clicked jQuery loads index.php?o=images when u click web it loads index.php?o=web Link to comment Share on other sites More sharing options...
justsomeguy Posted February 1, 2011 Share Posted February 1, 2011 Why don't you add Javascript click events to those links so that jQuery handles the click? Link to comment Share on other sites More sharing options...
ColdEdge Posted February 1, 2011 Author Share Posted February 1, 2011 ok but how would i do the updating of the container part with the search and such? Link to comment Share on other sites More sharing options...
justsomeguy Posted February 1, 2011 Share Posted February 1, 2011 In general, you replace the innerHTML of the container element, or you build a new node structure. For example, you could send an ajax request for the new content, and when the content comes back use it to replace the innerHTML of the container with the response. Link to comment Share on other sites More sharing options...
ColdEdge Posted February 1, 2011 Author Share Posted February 1, 2011 ok using this style$("#search_web").click(function(){ $('#wrapper').load('index.php?o=web&type=search');});this will workwhat should i add to make else statement if nothing was clicked to load index.php?o=basic ? Link to comment Share on other sites More sharing options...
justsomeguy Posted February 1, 2011 Share Posted February 1, 2011 If nothing was clicked, the click event will not fire. Link to comment Share on other sites More sharing options...
ColdEdge Posted February 1, 2011 Author Share Posted February 1, 2011 will this work?$("#search_web").click(function(){ $('#wrapper').load('index.php?o=web&type=search'); } else { $('#wrapper').load('index.php?o=search'); }); Link to comment Share on other sites More sharing options...
justsomeguy Posted February 1, 2011 Share Posted February 1, 2011 No, you can't have an else without an if. What are you trying to do? That click function only runs if someone clicks on the search_web element. I don't think you need an if/else. Link to comment Share on other sites More sharing options...
ApocalypeX Posted February 1, 2011 Share Posted February 1, 2011 You are essentially building a system to interpret, request and render pages based on anything after the #. It's not easy. Link to comment Share on other sites More sharing options...
justsomeguy Posted February 1, 2011 Share Posted February 1, 2011 This might be easier than he's (anime she's?) making it out to be though. You just need to understand the event model. When you make a web page, you just lay out a bunch of stuff that people can click on and it goes somewhere else. When you're using Javascript you're responding to specific events. An event is something like someone clicking on something, or the mouse going over a certain element, or the page resizing, certain actions which happen that you can respond to. Because he's using jQuery, the function posted in post 7 is only going to run when someone clicks on that one element. The only thing that piece of code does is respond when someone clicks on that one element, it doesn't respond when they click on anything else. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.