2014-07-02 3 views
0

Cela fonctionne dans Chrome, mais pas dans Safari:Comment faire de la radio: le travail sélectionné dans Safari

require(['jquery'], function($) 
{ 
    // store the value of the previous selected radio control 
    // before the current one gets selected 
    $(document).on('focus', 'input[type=radio]', function() { 
     // search all radio input fields with the same name within the same form 
     // and store the value of active one into the oldValue property 
     $(this).data('oldValue', $(this.form[this.name]).filter(':checked').val()); 
    }); 
}); 

Quelle partie de l'extrait est la cause du problème? Je suis Steppin' dans le noir ici ...

Répondre

1

changez cette ligne:

$(this).data('oldValue', $(this.form[this.name]).filter(':checked').val()); 

à ceci:

$(this).data('oldValue', $(this).closest('form').find(':checked').val()); 

Autre que cela, vous pouvez changer focus événement change :

$(document).on('change', 'input[type=radio]', function() { 
+0

qui n'a pas résolu mon problème B Il a attiré mon attention sur un problème plus fondamental: j'ai mis un console.log dans le bloc d'événements et je ne l'ai pas compris, donc il semble que tout l'événement ne soit pas déclenché quand j'utilise focus avec safari, voir ce violon: http://jsfiddle.net/TXLmk/ – ThinkTeamwork

+0

@PhilS ce violon n'a pas de code js. – Jai

+0

le violon est juste cette ligne qui ne fonctionne pas en safari – ThinkTeamwork

Questions connexes