Let's say for you example you have this array
//Defined at the top of your class
myArray = [];
//Then somewhere else in the code
myArray["unique_id"] = {example: true, example2: false, etc..};
//somewhere else
delete myArray["unique_id"];
Could it be possible to have something like this:
//when adding
myArray["unique_id"] = {example: true, example2: false, etc..};
myArray.trigger("array:update");
//when deleting
delete myArray["unique_id"];
myArray.trigger("array:delete");
//and in a different file or somewhere else down the path
myArray.on("array:update", function(){
//do stuff
});
//and in a different file or somewhere else down the path
myArray.on("array:delete", function(){
//do stuff
});
I like the custom event system and I was wondering if thats something possible. Didn't find examples on the documentation of this specific application. Basically attaching custom events to array/objects and not necessarily dom elements.
$("<div>")and then listen to my custom events on it. Would that be an acceptable hack ?Array?delete myArray["unique_id"];looks like you want to use a regular object. Arrays have the items stored with an index0..n, and not a string as index and removing an elment from an Array is not done usingdelete.triggerthedelete,updateevents manually.