[jQuery] Toggle Help
I am loading a page using $Ajax and upon success i run a toggle function. Now how can i set it up so that once its been loaded it will not make a second Ajax request? Basically a user clicks edit and i get the form via Ajax request and place it into a div. Once completed the original content toggles to the newly loaded form. If a user clicks cancel the form toggles revealing the original content. But if they click edit again it runs the request to get the form. But since its already been loaded and now just hidden in the div so i do not need to make the Ajax request call again $("a#mod_test").click(function(){ $('#test').after(''); $('.loading').fadeIn('normal'); $.ajax({ type: "POST", url: '/manage/account/edit', cache: true, success: function(data){ $('.loading').fadeOut('normal').remove(); $("#test").slideToggle('slow').toggleClass("hidden"); $("#testForm").html(data).slideToggle('slow'); } }); return false; }); How can I set a variable in the success function so that when the user clicks it checks to see if its been loaded already Something like this I tried but no go if (loadedAlready = false) { $.ajax({ type: "POST", url: '/manage/account/edit', cache: true, success: function(data){ loadedAlready = true; $('.loading').fadeOut('normal').remove(); $("#test").slideToggle('slow').toggleClass("hidden"); $("#testForm").html(data).slideToggle('slow'); } }); } else { $('.loading').fadeOut('normal').remove(); $("#test").slideToggle('slow').toggleClass("hidden"); $("#testForm").slideToggle('slow'); } Dave
[jQuery] Toggle Help
I am trying to toggle two different views on the page. I have the users personal info in content So when the user clicks edit the content gets replaced with a form url: "/manage/personal/edit", What would be the best way to do this/ So if they click edit the content gets replaced with the form, if they hit cancel the form gets replaces with the original content? $(document).ready(function(){ $("#edit_personal").click(function(){ $("#edit_personal").toggle().ajax(function(){ url: "/manage/personal/edit", cache: false }); return false; }); }); Thanks, Dave
[jQuery] Toggle Help
I want to build add a "favourites" type widget into my site. Just so a user can bookmark a post they like. So I have my standard paginated view with various posts and a star beside each post. Solid star = bookmarked, empty star = not bookmarked I have the save/delete bookmark working the star only changes on a page refresh. How would I use toggle for something like this? So when the user clicks on the star it changes to the opposite of what it is? And how do I then use the toggle to determine what star to display on page load? Ideas? Dave
[jQuery] Toggle Help
Im just starting out with jQuery. Im getting stuck though. Im trying to get jQuery to manipulate my form. Changing the drop down menus to a given value. It does the first toggle fine, but won't do the second. Could someone explain why and provide a solution. Ive been trying for hours. Heres what Ive got. $(document).ready(function(e){ $('a.typeswitch').click(function(e) { $('a.typeswitch').toggle( function () { $(".typeselect").attr("selected","TV Shows"); }, function () { $(".typeselect").attr("selected","Movies"); } ); }); }); Thanks :)