IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

Comment supprimer l'événement du parent ?


Sujet :

JavaScript

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2006
    Messages
    165
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Février 2006
    Messages : 165
    Points : 39
    Points
    39
    Par défaut Comment supprimer l'événement du parent ?
    Bonsoir,

    J'ai un souci d'héritage des événements en javascript.
    Pouvez-vous prendre un peu de votre temps pour m'aider ?

    la fonction "envoiDetails()" ne doit pas s'exécuter quand je clique sur comparer (case + label) !
    Je retourne le code dans tous les sens, je n'y arrive pas !

    Ceci doit fonctionner sous IE7+, FF, Chrome, Opera, safari...

    Pouvez-vous m'aider ?
    D'avance, un immense merci !

    Voici le code :
    Code js : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
     
    function liretablejson(jtable) {
    	oTable = "<table cellpadding='0' cellspacing='0' border='0'>";
    	oTable += "<tbody>";
    	oCol = 0;
    	oLig = 0;
    	aData = jtable.aaData;
    	triref = jtable.iTotalDisplayRecords;
    	maxref = jtable.iTotalRecords;
    	if (triref < (oFinArticle+1)) {
    		oFinArticle = triref - 1;
    	}
    	for (var ilire = oDebArticle; ilire <= oFinArticle; ilire++) {
    		Data = aData[ilire];
    		finition = Data[1];
    		switch (finition) {
    			case "WG":
    				matiere = "Or blanc";
    				break;
    			case "YG":
    				matiere = "Or jaune";
    				break;
    			case "PT":
    				matiere = "Platine";
    				break;
    			default:
    				matiere = "nc";
    				break;
    			}
    		description = Data[4];
    		oCol++;
    		if (oCol == 1) {
    			oTable += '<tr>';
    			oLig++;
    		}
    		oCellule  = "<td>";
    		oCellule += "<div class='case' onmouseover='search(" + oLig + ", " + oCol + ", \"" + Data[0] + "\");' onmouseout='nosearch();' onClick='envoiDetails(\"" + Data[0] + "\");'>";
    		oCellule += "  <img class='image_1m invisible' src='" + dossvue02+Data[11] + "' alt='bague' />";
    		oCellule += "  <img class='image_1 invisible' src='" + dossvue02+Data[11] + "' alt='bague' />";
    		oCellule += "  <img class='image_0' src='" + dossvue01+Data[10] + "' alt='bague' />";
    		oCellule += "  <div class='comp' id='tag" + Data[0] + "' alt='recherche'>";
    		oCellule += "    <input id='comparer[\"" + Data[0] + "\"]' type='checkbox' class='curseur' onClick='acomparer(\"" + Data[0] + "\");'>";
    		oCellule += "    <label for='comparer[\"" + Data[0] + "\"]'>&nbsp;Comparer</label>";
    		oCellule += "  </div>";
    		oCellule += "  <img class='loupe invisible' src='diamants/images/general/loupenoire.gif' alt='recherche' />";
    		oCellule += "  <div class='informations'>";
    		oCellule += "  <p class='case01'>"+Data[2]+" - <span class='grisfonce c11'>" + matiere + "</span></p>";
    		oCellule += "  <p class='case02'><span class='grisfonce'>" + description.slice(0,70) + "...</span></p>";
    		oCellule += "  <p class='case03'>"+Data[6]+" &euro;</p>";
    		oCellule += "  </div>";
    		oCellule += "</div>";
    		oCellule += "</td>";
    		oTable += oCellule;
    		if (oCol == mCol || ilire == oFinArticle) {
    			oCol = 0;
    			oTable += '</tr>';
    		}
    	}
    	oTable += "</tbody>";
    	oTable += "</table>";
    	document.getElementById("bloc3102").innerHTML=oTable;
    }
     
    function acomparer(sref) {
    	alert(sref);
    	var swTrouve=-1;
    	for (var k=0; k<ckComparer.length; k++) {
    		if (ckComparer[k] == sref) {
    			swTrouve=k;
         			k=ckComparer.length;
    		}
    	}
    	if (swTrouve < 0) {
    		ckComparer.push(sref);
    	} else {
    		ckComparer[swTrouve] = 0;
    	}
    }

  2. #2
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 665
    Points
    66 665
    Billets dans le blog
    1
    Par défaut
    fais une recherche avec cancelBubble() et stopPropagation()

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2006
    Messages
    165
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Février 2006
    Messages : 165
    Points : 39
    Points
    39
    Par défaut
    Tout ceci est vrai en jquery...
    Mais ici, je n'utilise pas jquery.
    Alors comment faire autrement ?
    Une idée pour m'aider ?

  4. #4
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 665
    Points
    66 665
    Billets dans le blog
    1
    Par défaut


    qui a parlé de jquery ... ??????????????????

  5. #5
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2006
    Messages
    165
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Février 2006
    Messages : 165
    Points : 39
    Points
    39
    Par défaut
    Sorry. Je croyais !

    Mais tu peux m'aider un peu plus,
    à mettre cela en place avec stoppropagation() ?

    A l'aide, stp

  6. #6
    Modérateur

    Avatar de NoSmoking
    Homme Profil pro
    Inscrit en
    Janvier 2011
    Messages
    17 110
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2011
    Messages : 17 110
    Points : 44 921
    Points
    44 921
    Par défaut
    Bonjour,
    une petite recherche sur le site te serait bénéfique...
    http://www.developpez.com/recherche/...&sa=Rechercher

  7. #7
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2006
    Messages
    165
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Février 2006
    Messages : 165
    Points : 39
    Points
    39
    Par défaut
    J'ai pourtant essayé (après plein de lectures)...
    Mais ceci ne fonctionne pas...

    Pouvez-vous m'aider à y voir plus clair ?
    D'avance, un immense merci.

    Voici mon nouveau code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
     
    	function liretablejson(jtable) {
    		oTable = "<table cellpadding='0' cellspacing='0' border='0'>";
    		oTable += "<tbody>";
    		oCol = 0;
    		oLig = 0;
    		aData = jtable.aaData;
    		triref = jtable.iTotalDisplayRecords;
    		maxref = jtable.iTotalRecords;
    		oMessage = "";
    		if (cut != "rond") {
    			oMessage += "<p style='text-align:center; margin-top:18px;'>";
    			oMessage += "Auncun solitaire ne convient pas<br>pour votre diamant de forme <span class='bold'>" + cut + "</span> !<br><br>";
    			oMessage += "N'h&eacutesitez surtout pas &agrave nous <a href='mailto:david@celinni.com'>recontactez par email</a> !<br><br>";
    			oMessage += "Vous pouvez aussi <a href='recherche-diamant.htm'>choisir un autre diamant</a> !<br><br>";
    			oMessage += "</p>";
    			triref=0;
    			document.getElementById("bloc3102").innerHTML=oMessage;
    			return;
    		}
    		if (carat < .2) {
    			oMessage += "<p style='text-align:center; margin-top:18px;'>";
    			oMessage += "Auncun solitaire ne convient pas<br>pour le poids de votre diamant < 0.20 carats (<span class='bold'>" + carat + " carats</span>) !<br><br>";
    			oMessage += "N'h&eacutesitez surtout pas &agrave nous <a href='mailto:david@celinni.com'>recontactez par email</a> !<br><br>";
    			oMessage += "Vous pouvez aussi <a href='recherche-diamant.htm'>choisir un autre diamant</a> !<br><br>";
    			oMessage += "</p>";
    			triref=0;
    			document.getElementById("bloc3102").innerHTML=oMessage;
    			return;
    		}
    		if (triref == 0) {
    			oMessage += "<p style='text-align:center; margin-top:18px;'>";
    			oMessage += "Aucun solitaire n'existe pas<br>suivant vos crit&egrave;res de s&eacute;lection ci-dessus !<br><br>"
    			oMessage += "N'h&eacutesitez surtout pas &agrave nous <a href='mailto:david@celinni.com'>recontactez par email</a> !<br><br>";
    			oMessage += "Vous pouvez aussi <a href='recherche-diamant.htm'>choisir un autre diamant</a> !<br><br>";
    			oMessage += "</p>";
    			document.getElementById("bloc3102").innerHTML=oMessage;
    			return;
    		}
    		if (triref < (oFinArticle+1)) {
    			oFinArticle = triref - 1;
    		}
    		for (var ilire = oDebArticle; ilire <= oFinArticle; ilire++) {
    			Data = aData[ilire];
    			finition = Data[1];
    			switch (finition) {
    				case "WG":
    					matiere = "Or blanc";
    					break;
    				case "YG":
    					matiere = "Or jaune";
    					break;
    				case "PT":
    					matiere = "Platine";
    					break;
    				default:
    					matiere = "nc";
    					break;
    			}
    			description = Data[4];
    			oCol++;
    			if (oCol == 1) {
    				oTable += '<tr>';
    				oLig++;
    			}
    			oCellule  = "<td>";
    			oCellule += "<div id='bulle" + Data[0] + "' class='case' onmouseover='search(" + oLig + ", " + oCol + ", \"" + Data[0] + "\");' onmouseout='nosearch();' onClick='envoiDetails(\"" + Data[0] + "\");'>";
    			oCellule += "  <img class='image_1m invisible' src='" + dossvue02+Data[11] + "' alt='bague' />";
    			oCellule += "  <img class='image_1 invisible' src='" + dossvue02+Data[11] + "' alt='bague' />";
    			oCellule += "  <img class='image_0' src='" + dossvue01+Data[10] + "' alt='bague' />";
    			oCellule += "  <div id='tag" + Data[0] + "' class='comp' alt='recherche'>";
    			oCellule += "    <input id='comparer[\"" + Data[0] + "\"]' type='checkbox' class='curseur' onClick='acomparer(\"" + Data[0] + "\"); stopPropagation(event);'>";
    			oCellule += "    <label for='comparer[\"" + Data[0] + "\"]'>&nbsp;Comparer</label>";
    			oCellule += "  </div>";
    			oCellule += "  <img class='loupe invisible' src='diamants/images/general/loupenoire.gif' alt='recherche' />";
    			oCellule += "  <div class='informations'>";
    			oCellule += "  <p class='case01'>"+Data[2]+" - <span class='grisfonce c11'>" + matiere + "</span></p>";
    			oCellule += "  <p class='case02'><span class='grisfonce'>" + description.slice(0,70) + "...</span></p>";
    			oCellule += "  <p class='case03'>"+Data[6]+" &euro;</p>";
    			oCellule += "  </div>";
    			oCellule += "</div>";
    			oCellule += "</td>";
    			oTable += oCellule;
    			if (oCol == mCol || ilire == oFinArticle) {
    				oCol = 0;
    				oTable += '</tr>';
    			}
    		}
    		oTable += "</tbody>";
    		oTable += "</table>";
    		document.getElementById("bloc3102").innerHTML=oTable;
    	}
    avec bien sûr les fonctions :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
     
    	function cocherComparer(sref) {
    		var nocomparaison = "comparer["+sref+"]";
    		if (document.getElementById(nocomparaison).checked == false) {
    			document.getElementById(nocomparaison).checked = true;
    		} else {
    			document.getElementById(nocomparaison).checked = false;
    		}
    		acomparer(sref);
    	}
     
    	function acomparer(sref) {
    		alert(sref);
    		var swTrouve=-1;
    		for (var k=0; k<ckComparer.length; k++) {
    			if (ckComparer[k] == sref) {
    				swTrouve=k;
         			k=ckComparer.length;
    			}
    		}
    		if (swTrouve < 0) {
    			ckComparer.push(sref);
    		} else {
    			ckComparer[swTrouve] = 0;
    		}
    	}
     
    	function stopPropagation(event) {
    		var event = e || window.event;
    		if (event.stopPropagation) {
    			event.stopPropagation();
    		} else {
    			event.cancelBubble = true;
    		} 
    	}

  8. #8
    Modérateur

    Avatar de NoSmoking
    Homme Profil pro
    Inscrit en
    Janvier 2011
    Messages
    17 110
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2011
    Messages : 17 110
    Points : 44 921
    Points
    44 921
    Par défaut
    Dans ce cas passe par la délégation de l'événement
    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    <!DOCTYPE html>
    <html lang="fr">
    <head>
    <meta charset="UTF-8">
    <title>[Délégation event]</title>
    <style>
    div{
      width:500px;
      height:500px;
      background:#ABC;
    }
    </style>
    <script>
    function fctAction(e){
      var src = e.target || e.srcElement;
      alert( src.id || 'je n\'ai pas d\'id mais j\ai du pétrole!');
    }
    </script>
    </head>
    <body>
    <div onclick="fctAction(event);">
      <input id="check_1" type="checkbox"><br>
      <input id="check_2" type="checkbox">
    </div>
    </body>
    </html>

  9. #9
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2006
    Messages
    165
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Février 2006
    Messages : 165
    Points : 39
    Points
    39
    Par défaut
    Hé, c'est super ce truc !!!
    Grand merci pour ton aide !

  10. #10
    Modérateur

    Avatar de NoSmoking
    Homme Profil pro
    Inscrit en
    Janvier 2011
    Messages
    17 110
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2011
    Messages : 17 110
    Points : 44 921
    Points
    44 921
    Par défaut
    Au vu de ton code tu peux même remonter la gestion de l'événement au niveau de la TABLE.

  11. #11
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2006
    Messages
    165
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Février 2006
    Messages : 165
    Points : 39
    Points
    39
    Par défaut
    Bien vu !
    Merci.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Comment supprimer les doublons
    Par djelloulc dans le forum MS SQL Server
    Réponses: 9
    Dernier message: 17/09/2013, 14h30
  2. Réponses: 2
    Dernier message: 22/06/2011, 15h21
  3. Réponses: 15
    Dernier message: 12/11/2008, 07h38
  4. [C#] Débutant. Comment supprimer la gestion d'un évènement.
    Par Pierre8r dans le forum Windows Forms
    Réponses: 2
    Dernier message: 10/04/2006, 16h16
  5. Comment supprimer 'mots recherchés'?
    Par bucky dans le forum Windows XP
    Réponses: 3
    Dernier message: 04/12/2003, 17h06

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo