[Web2.0] Jquery (sono all'inizio)

Simone Volpini simonevolpini a yahoo.it
Mer 11 Lug 2007 09:19:39 CEST


Simone Volpini wrote:
> P.S: Toggle, ad una prima occhiata da neofita, non sono sicuro faccia al
> caso mio.

Cambiato idea, direi che Toggle fa al caso mio :)

Praticamente lo uso cosi:

 $("a").toggle(function(){
   alert('prova 1');
 },function(){
   alert('prova 2');
 });

http://www.c--s.net/ajax/index3_table.php


Solo che io vorrei far cambiare il link "STATO" in base al suo effettivo
stato (attivo, disattivo), ma nel momento in cui sostituisco il
contenuto del link

$("a").toggle(function(){
   alert('prova 1');
   $("#att_1 > #test").empty();
   $("#att_1 > #test").append('<strong><a>ON</a></strong>');
 },function(){
   alert('prova 2');
 });

devo rifare il bind di "a" (in questo caso il toggle se non sbaglio).

Il problema è che nel momento in cui riclicco nuovamente sullo stesso
record e cambio lo stato devo nuovamente rifare il bind (e cosi via in
maniera ricorsiva):

$("a").toggle(function(){
    alert('prova 1');
    $("#att_1 > #test").empty();
    $("#att_1 > #test").append('<strong><a>ON</a></strong>');
    $("a").toggle(function(){
        alert('prova 1');
        $("#att_1 > #test").empty();
        $("#att_1 > #test").append('<strong><a>OFF</a></strong>');
        $("a").toggle(function(){
            alert('prova 1');
            $("#att_1 > #test").empty();
            $("#att_1 > #test").append('<strong><a>ON</a></strong>');
        },function(){
            alert('prova 2');
        });
    },function(){
        alert('prova 2');
    });
},function(){
    alert('prova 2');
});


che ovviamente è assurdo! :)
C'e' sicuramente un altro metodo che non conosco.
Intanto continuo a googolare, ma se avete qualche idea, sono ben accette ;)

Grazie,
Simone


Maggiori informazioni sulla lista Web2.0