Last active
February 6, 2018 01:20
-
-
Save TommyZG/8d5ffaf94f4b48a5e48b229ee90e7f71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ******************* Scroll to element's position | |
//get parameters are iteration of all objects selected by .selection | |
$(".selection").get(0).scrollIntoView(); | |
// ******************* Check if checkbox is checked | |
$(".checkbox").on("change", function () { | |
if ($(this).is(":checked")) { | |
doSomething(); | |
} else { | |
doSomething(); | |
} | |
}); | |
// ******************* Check checkbox | |
$(".checkbox").prop('checked', true); | |
// ******************* Check radio or checkbox depending on value from backend (user.gender = value - "M") | |
$('input[name="gender"]').filter('[value=' + user.gender + ']').prop("checked", true); | |
/** | |
* Group array by key | |
* @param {array} xs array to group | |
* @param {string} key string of key to group by | |
* @returns {Object} | |
*/ | |
var groupBy = function (xs, key) { | |
return xs.reduce(function (rv, x) { | |
(rv[x[key]] = rv[x[key]] || []).push(x); | |
return rv; | |
}, {}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment