Skip to content

Instantly share code, notes, and snippets.

@chrislkeller
Created November 21, 2014 23:28
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 chrislkeller/c66ccd9cd677c148ccf9 to your computer and use it in GitHub Desktop.
Save chrislkeller/c66ccd9cd677c148ccf9 to your computer and use it in GitHub Desktop.
Silly Javascript for backbone...
getCheckboxIds: function(event){
var activeCheckboxes = [];
if (!$("input:checkbox").is(":checked")) {
console.log("box is not checked");
}
$("input:checkbox").each(function(){
var $this = $(this);
if($this.is(":checked")){
var categoryId = $this.attr("id");
if (categoryId != undefined){
activeCheckboxes.push(categoryId);
}
}
});
this.findModelsForMarkers(this.mapDataObject, activeCheckboxes);
},
findModelsForMarkers: function(mapDataObject, activeCheckboxes){
var collection = mapDataObject.queriedCollisions;
var arrayOfModels = [];
_.each(activeCheckboxes, function(value){
if (value === "pedcol"){
var peds = collection.where({
pedcol: "Y"
});
arrayOfModels.push(peds);
} else if (value === "biccol"){
var bikes = collection.where({
biccol: "Y"
});
arrayOfModels.push(bikes);
} else {
var all = collection.where({
biccol: "",
pedcol: ""
});
arrayOfModels.push(all);
}
});
var flattenedArray = _.flatten(arrayOfModels)
this.createMarkers(flattenedArray);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment