![]() |
Have to click twice to load Ajax Data. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Have to click twice to load Ajax Data. (/showthread.php?tid=40471) |
Have to click twice to load Ajax Data. - El Forum - 04-09-2011 [eluser]sbarow[/eluser] Hey, Pretty new to Ajax. I am trying to make a gallery, where all the images in the database will be show. An image can then be clicked and it will take you to the top of the page and the image clicked will be loaded into the main div view. This is the code for the view. Code: <div id="work_gallery"> I then have that info posting to this controller function Code: function work_images($id) And finally here is my Javascript Code: [removed] The whole thing works fine. Except that you have to click twice on an image for it to actually load. This is not ideal. Can any one explain why this is happening and how I can fix the problem? Thanks in advance. Have to click twice to load Ajax Data. - El Forum - 04-09-2011 [eluser]InsiteFX[/eluser] Try using prevent default InsiteFX Have to click twice to load Ajax Data. - El Forum - 04-09-2011 [eluser]sbarow[/eluser] I have no idea what that means? Have to click twice to load Ajax Data. - El Forum - 04-09-2011 [eluser]InsiteFX[/eluser] If your using jQuery goto the jQuery site and search on prevent default InsiteFX Have to click twice to load Ajax Data. - El Forum - 04-09-2011 [eluser]sbarow[/eluser] Seems the issue was I had to bind the event handler to the links as they where created dynamically. Here is the fixed code if any one is interested. Code: function get_images(id) { Have to click twice to load Ajax Data. - El Forum - 04-09-2011 [eluser]InsiteFX[/eluser] jQuery is a great site with a lot of examples that are great for learning InsiteFX |