orbit-4-2/app/assets/javascripts/member-selection.js

49 lines
1.3 KiB
JavaScript

$(document).ready(function() {
$(".select_user_modal").on('click', function(){
var ids = [];
var users = $('.selected_user');
users.each(function(i) {
ids.push(users.eq(i).attr('id'));
});
$("#main-wrap").after("<span id='select_user'></span>");
$.ajax({
type: 'GET',
url: $(this).attr("rel"),
dataType: 'script',
data: {ids: ids},
success: function (msg) {
$("#member-filter").modal('show'); },
error: function(){
// TODO: i18n in javascript
alert("ERROR");
}
});
return false;
});
$("#remove_users").on('click', function(){
var ids = [];
var users = $('.selected_user input[type="checkbox"]:checked');
users.each(function(i) {
ids.push(users.eq(i).parent().attr('id'));
});
if (users.size() > 0) {
// TODO: i18n in javascript
if (confirm('Are you sure you want to delete this?')) {
$.ajax({
type: 'DELETE',
url: $(this).attr("rel"),
dataType: 'script',
data: {ids: ids},
error: function(){
// TODO: i18n in javascript
alert("ERROR");
}
});
}
}
else {
// TODO: i18n in javascript
alert('You did not select anything to delete')
}
});
});