After trying the use of 'live' method, I obtained something a bit
better.
Heres my code for now :
/*
 *
 * @author simiand
 *
 */
$(document).ready(function(){


    /*
     * BOF // Fonction pour garder la session active
     */
    var sessionKeepAlive = 10000 * 50;
    function keepSessionAlive(){
        $.ajax({
            url: '/actions/keepAlive',
            success: function(data){
                setTimeout(function(){
                    keepSessionAlive();
                }, sessionKeepAlive);
            },
            error: function(XMLHttpRequest, textStatus, errorThrown){
                alert('Session perdue, veuillez vous reconnecter.');

                setTimeout(function(){
                    keepSessionAlive();
                }, sessionKeepAlive);
            }
        });
    }
    keepSessionAlive();

    /*
     * EOF // Fonction pour garder la session active
     */
    /*
     * BOF // Fonction de gestion / validation/ Submit du formulaire
de coordonnées de facturation
     */
    function validerSubmitCoordsFacturation(){
        $("#formulaireFinalCreationCompte").validate({
            errorPlacement: function(error, element){
                error.appendTo(element);
            },
            rules: {
                facturationCivilite: "required",
                facturationNom: "required",
                facturationPrenom: "required",
                facturationAdresse1: "required",
                facturationCodePostal: {
                    required: true,
                    rangelength: [5, 5],
                    number: true
                },
                facturationVille: "required",
                facturationTel: {
                    number: true,
                    required: true
                },
                facturationEmail: {
                    required: true,
                    email: true
                }
            },
            submitHandler: function(form){
                var action = $(form).attr('action');
                var data = $(form).serialize();
                $.ajax({
                    cache: false,
                    url: action,
                    data: data,
                    success: function(reponseJSON){
                        $('#coordonneesFacturation').empty();
                        $('#coordonneesFacturation').html
(reponseJSON);
                    }
                });
            }
        });
    }
    /*
     * EOF // Fonction de gestion / validation/ Submit du formulaire
de coordonnées de facturation
     */


        var articleEnCoursVal ;
        $(".quantite").live("focus",function(){
                articleEnCoursVal = parseInt($(this).val());
        });

    $(".quantite").live("change", function(){

        var formulaire = $(this).parents("form:first");
        var action = $(formulaire).attr('action');

        action = $(formulaire).attr('action');
        var nouvelleValeur = parseInt($(this).val());

        var articleId = $(this).next('input:hidden').val();
        var quantite = $(this).val();
        var data;
        if (articleEnCoursVal != 0 && articleEnCoursVal !=
nouvelleValeur) {
            action = '/actions/actualierPanierCommande';
            data = '';
            $("form input.quantite").each(function(){
                data += $(this).attr('name');
                data += "=";
                data += $(this).val();
                data += "&";
            })
        }
        else {
            data = "articleId=";
            data += articleId;
            data += "&";
            data += "quantite=";
            data += quantite;
            if ($(this).parents("tr:first").find
('#prixUnitaireArticle').length != 0) {
                var prixUnitaireArticle = $(this).parents
("tr:first").find('#prixUnitaireArticle').val();
                data += "&";
                data += "prixUnitaireArticle=";
                data += prixUnitaireArticle;
            }
        }

        $.ajax({
            url: action,
            data: data,
            cache: false,
            dataType: "json",
            success: function(reponseJSON){
                $("#panierDetail tbody").empty();
                generationTable(reponseJSON);
            }
        });
    });



    function generationTable(reponse){
        for (var x = 0; x < reponse.articles.length; x++) {
            var articleRow = $("<tr>").addClass
("ligneArticlePrincipal").appendTo("#panierDetail tbody");
            $("<td>").addClass("libelleArticlePrincipal").text
(reponse.articles[x].libelle).appendTo(articleRow);

            var prixAffiche = parseInt(reponse.articles
[x].prixAffiche);
            if (prixAffiche != 0) {
                $("<td>").addClass('prixTotalLigne').text
(reponse.articles[x].prixAffiche).appendTo(articleRow);
            }
            else {
                $("<td>").html('<input type="text"
id="prixUnitaireArticle" value="0" name="prixCommandeCarte"/
>').appendTo(articleRow);
            }
            var inputText = $("<td>").html('<input type="text"
id="quantitePrincipal" class="quantite" value="' + reponse.articles
[x].quantite + '" name="quantiteLigneCommande(' + reponse.articles
[x].id + ')"/>').appendTo(articleRow);
            var inputHidden = $("<input type=\"hidden\"/>").attr
('value', reponse.articles[x].id).attr('id',
'articlePrincipalCourantId').attr('name',
'articlePrincipalCourantId');

            var remiseLigneArticle = $("<td>").addClass
('remiseLigneArticle').html('<span id="remiseLigneArticle">' +
reponse.articles[x].montantRemise + '</span>').appendTo(articleRow);

            $(inputHidden).appendTo(inputText);
            var prixTotalArticle = "00,00";
            if (reponse.articles[x].prixTotal != "") {
                prixTotalArticle = reponse.articles[x].prixTotal;
            }
            var totalLigneArticle = $("<td>").addClass
('prixTotalLigne').html('<span id="totalArticle">' + prixTotalArticle
+ '</span>').appendTo(articleRow);
        }
        if (reponse.totalPanier.length > 0) {
            $("tfoot td.prixTotalLigne").html(reponse.totalPanier);
        }
    }





    var adresseDelivraison = "/actions/commande/
adresseDestinataireFormulaireCommande";

    function rafraichirCoordonnesLivraison(){
        $.ajax({
            cache: false,
            url: adresseDelivraison,
            success: function(reponseFormulaire){
                $("#coordoneesLivraison").html("");
                                
$('#coordoneesLivraison').html(reponseFormulaire);
                gestionCheckboxesLivraison();
            }
        });
    }

    function gestionCheckboxesLivraison(){
        if ($("#beneficiaire").is(':checked')) {
            $("#renseignementLivraison").show();
            $("#renseignementAcheteur").hide();
            $("#domicile").attr('checked', false);
            $(".lieuLivraison").html("Au domicile du bénéficiaire");
        }

        if ($("#domicile").is(':checked')) {
            $("#renseignementAcheteur").show();
            $("#renseignementLivraison").hide();
            $("#beneficiaire").attr('checked', false);
            $(".lieuLivraison").html("A domicile");
        }

        $("#beneficiaire").click(function(){
            if ($(this).is(':checked')) {
                $("#renseignementLivraison").show();
                $("#renseignementAcheteur").hide();
                $("#domicile").attr('checked', false);
                $(".lieuLivraison").html("Au domicile du
bénéficiaire");
            }
            else {
                $(this).attr('checked', true);
                $("#renseignementLivraison").hide();
            }
        });

        $("#domicile").click(function(){
            if ($(this).is(':checked')) {
                $("#renseignementAcheteur").show();
                $("#renseignementLivraison").hide();
                $("#beneficiaire").attr('checked', false);
                $(".lieuLivraison").html("A domicile");
            }
            else {
                $(this).attr('checked', true);
                $("#renseignementAcheteur").hide();
            }
        });
    }


    $("#adresseLivraison input[type=text]").live('change',function(){

            var formulaireEncours = $("form#adresseLivraison");
            var adresseDelivraison = '/actions/commande/
enregistrerCoordonneesLivraisonCommande';
            var data = $(formulaireEncours).serialize();
            $.ajax({
                cache: false,
                url: adresseDelivraison,
                data: data,
                success: function(reponseFormulaire){
                $("#coordoneesLivraison").html("");
                                
$('#coordoneesLivraison').html(reponseFormulaire);
                gestionCheckboxesLivraison();
                }
            });
    });





        /*
         * BOF // ensembles de fonctions ajax pour charger les differents
formulaires de l'interface
         */

        //
        //------Le chargement AJAX du panier
        //
        if ($("table#panierDetail").length > 0) {
                $.ajax({
                        url: "/actions/formulaireArticles",
                        data: "referenceVitrine=CARTEBESTCADEAUX",
                        dataType: "json",
                        success: function(reponse){
                                generationTable(reponse)
                        }
                });
        }

        //
        //------Le chargement AJAX des coordonnées de facturation
        //
    if ($('#coordonneesFacturation').length > 0) {
        $.ajax({
            cache: false,
            url: "/actions/commande/
editerCoordonneesFacturationCommande",
            success: function(reponseFormulaireFacturation){
                $('#coordonneesFacturation').empty();
                $('#coordonneesFacturation').html
(reponseFormulaireFacturation);
            }
        });
    }

        //
        //------Le chargement AJAX des coordonnées de livraison
        //
    if ($("div#coordoneesLivraison").length > 0) {
        rafraichirCoordonnesLivraison();
    }


});


Bascially, what happens now in IE7 is quite strange when submitting
form with method
rafraichirCoordonnesLivraison(){
        $.ajax({
            cache: false,
            url: adresseDelivraison,
            success: function(reponseFormulaire){
                $("#coordoneesLivraison").html("");
                                
$('#coordoneesLivraison').html(reponseFormulaire);
                gestionCheckboxesLivraison();
            }
        });
    }

IE seems to submit form on change, but the returned result never
appears, instead I have a white space.

Second problem, the JSON loading in method
$.ajax({
                        url: "/actions/formulaireArticles",
                        data: "referenceVitrine=CARTEBESTCADEAUX",
                        dataType: "json",
                        success: function(reponse){
                                generationTable(reponse)
                        }
                });
Works like a charm in FF, but nothing gets loaded in IE. The JSON
response looks like this :
{


                        "totalPanier":"210,00&euro;",



        "articles": [
















                                                        {
                                                                
"id":"8a8b8d632481567f01248156fac90009",
                                                                
"prixAffiche":"0,00",
                                                                "quantite":"0",
                                                                
"libelle":"Carte BEST CADEAUX à montant variable",
                                                                "montantRemise" 
:"",
                                                                
"prixTotal":"00,00&euro;"
                                                        },





                                                                {
                                                                        
"id":"8a8b8d2e25682b6101256945ba940041",
                                                                        
"prixAffiche":"80,00",
                                                                        
"quantite" : "2",
                                                                        
"libelle":"Carte BEST CADEAUX 80 Euros",
                                                                        
"montantRemise" :"",
                                                                        
"prixTotal":"160,00 &euro;"
                                                                },












                                                                {
                                                                        
"id":"8a8b8d2e25682b6101256945c89e0042",
                                                                        
"prixAffiche":"50,00",
                                                                        
"quantite" : "1",
                                                                        
"libelle":"Carte BEST CADEAUX 50 Euros",
                                                                        
"montantRemise" :"",
                                                                        
"prixTotal":"50,00 &euro;"
                                                                },












                                                        {
                                                                
"id":"8a8b8d632481567f012481570549000e",
                                                                
"prixAffiche":"30,00",
                                                                "quantite":"0",
                                                                
"libelle":"Carte BEST CADEAUX 30 Euros",
                                                                "montantRemise" 
:"",
                                                                
"prixTotal":"00,00&euro;"
                                                        },









                                                        {
                                                                
"id":"8a8b8d632481567f012481570364000d",
                                                                
"prixAffiche":"15,00",
                                                                "quantite":"0",
                                                                
"libelle":"Carte BEST CADEAUX 15 Euros",
                                                                "montantRemise" 
:"",
                                                                
"prixTotal":"00,00&euro;"
                                                        },




        ]
}
I was suspecting that trailing comma, so I made a test hardcoding this
normally dynamic server answer, deleting that comma, but with no
better luck.
What am I missing ?

--

You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en.


Reply via email to