Skip to content

Instantly share code, notes, and snippets.

@cbonnissent
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbonnissent/a8988b8dd37bdad6000b to your computer and use it in GitHub Desktop.
Save cbonnissent/a8988b8dd37bdad6000b to your computer and use it in GitHub Desktop.
documentController event
$.ready(function() {
var myDocumentCheck = function(document) { return document.family.name === "ANIMAL" && document.view.id === "view1"};
//Ajouter un event au ready
window.dcp.document.documentController("addEvent", "ready", {
"documentCheck" : myDocumentCheck,
"name" : "myEvent.animal"
}, function(document) {
$(this).documentController("setValue", "animal_title", "toto");
});
// Lister les événements
window.dcp.document.documentController("listEvents");
[{ "name" : "myEvent.animal", "documentCheck" : function(...) {...}, "callBack" : function(...) {...}},...]
//Supprimer les événements
window.dcp.document.documentController("removeEvent", ".animal");
[]
//Change
window.dcp.document.documentController("addEvent", "change", {
"documentCheck" : myDocumentCheck,
"name" : "ichange.animal"
}, function(document, attribute) {
if(attribute.id === "animal_title") {
$(this).documentController("showMessage", "You have changed");
}
$(this).documentController("showMessage", "I have changed");
});
// Éteindre la lumière derrière soit
window.dcp.document.documentController("addEvent", "close", {
"documentCheck" : myDocumentCheck,
"name" : "close.animal"
}, function(document) {
$(this).documentController("removeEvent", ".animal");
});
});
@CircleCode
Copy link

  • Lors de la suppression d'un ou de plusieurs événements, le retour devrait être les événements supprimés.
  • Lors de l'ajout, tu n'indiques pas si ça retourne quelque chose (pour être honnête, je ne sais pas ce que ça peut retourner d'utile, mais je me pose la question…) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment