[jQuery] Re: Beginner question about toogeling a status
On Mon, Dec 22, 2008 at 7:20 AM, heohni heidi.anselstet...@consultingteam.de wrote: This: status.addClass(the_new_status); prints the new status, but the browser does not show the image which is connected with the new status class? Can I somehow refresh the div only? Is that possible? Sorry for the delay; I've been away. If you set things up the way I was thinking, changing the class should only change the position of the image, not the image, itself. It would be a single image composed of each of the single status images. If the status class is first removed, then the new class applied, it should work.
[jQuery] Re: Beginner question about toogeling a status
Hi Brian! your idea was great! Thanks! It works all very well expect one little piece On 11 Dez., 18:50, brian bally.z...@gmail.com wrote: Something like this: $(document).ready(function(){ $('div.statusimg').click(function() { var status = this; var her_id = status.id; /* remove all 2nd classes to reveal default state (eg. animation) */ $(status).removeClass('active', 'inactive', 'no_login'); $.ajax({ type: POST, url: /admin/ajax_toogle_manufacturer_status.php, data: her_id= +her_id, success: function(msg){ /* get the new status from the returned data */ status.addClass(the_new_status); } }); }) }); This: status.addClass(the_new_status); prints the new status, but the browser does not show the image which is connected with the new status class? Can I somehow refresh the div only? Is that possible? Thanks Heidi
[jQuery] Re: Beginner question about toogeling a status
Hi, is there someone who can give me a hand with that topic? Please? On 11 Dez., 16:30, heohni [EMAIL PROTECTED] wrote: Hi, this is my first post, I hope I do everything right! I have a list of users and for each user I have a little img showing the actual status which is eather - active - in-active - active but no login On click on this little img icon, I want to call a ajax php script which toogles the status. Therefore I need to parse 2 variables to my script, the user's ID and the current status ID. At the moment my link looks like this: img src=/img/online.gif alt= id={$hersteller_daten[her].her_id} name={$hersteller_daten[her].status} width=15 height=15 border=0 class=statusimg style=cursor: pointer; My Jquery is this at the moment: $(document).ready(function(){ $('img.statusimg').click(function() { var her_id = this.id; var status = this.name; $.ajax({ type: POST, url: /admin/ajax_toogle_manufacturer_status.php, data: her_id= +her_id+ status= + status, success: function(msg){ alert( Rückgabewert: + msg ); $('.statusimg').attr(src, /img/offline.gif); } }); }) }); For the moment I toogle only active into inactive. Because I do not know how to send 2 information (user's ID and the current status ID) to my jquery function. Can you help me with this please? Thanks! Heidi
[jQuery] Re: Beginner question about toogeling a status
On Thu, Dec 11, 2008 at 10:30 AM, heohni [EMAIL PROTECTED] wrote: Hi, this is my first post, I hope I do everything right! Most of us only post questions here when we're doing something wrong ;-) For the moment I toogle only active into inactive. Because I do not know how to send 2 information (user's ID and the current status ID) to my jquery function. Do you mean from the PHP script? What is it returning? Anyway, I once did something quite similar. div class=statusimg inactive id={$hersteller_daten[her].her_id}/div CSS: .statusimg { width: 15px; height: 15px; cursor: pointer; background: transparent url(/img/status.gif) 0 0 no-repeat; } .statusimg.inactive { background-position: 15px 0; } .statusimg.active { background-position: 30px 0; } .statusimg.no_login { background-position: 45px 0; } Where status.gif is a 60px x 15px image divided into 4 states. The square at far left (0 0) represents the loading state when you do your AJAX call. This could be animated in some way. @ |inactive | active| no_login I don't think you should need to send the status to the server because that information should already be there. All your script should need to know is the ID. With that, it should be able to look up the current status in the session, DB, etc. When the page first loads, you should set the 2nd class on each div accordingly (ie. statusimg inactive, statusimg active, etc.) That's important because, otherwise, you'll have a bunch of twirling animations. Something like this: $(document).ready(function(){ $('div.statusimg').click(function() { var status = this; var her_id = status.id; /* remove all 2nd classes to reveal default state (eg. animation) */ $(status).removeClass('active', 'inactive', 'no_login'); $.ajax({ type: POST, url: /admin/ajax_toogle_manufacturer_status.php, data: her_id= +her_id, success: function(msg){ /* get the new status from the returned data */ status.addClass(the_new_status); } }); }) }); How you get the new status className depends on what your PHP script returns.