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

54 lines
1.4 KiB
JavaScript
Raw Normal View History

$(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',
2014-02-11 06:42:12 +00:00
data: {field: $(this).attr("field"), ids: ids},
success: function (msg) {
$("#member-filter").modal('show'); },
error: function(){
// TODO: i18n in javascript
alert("ERROR");
}
});
return false;
});
2014-02-11 06:42:12 +00:00
$(document).on('click', ".remove_user", function(){
$(this).parent().remove();
});
$("#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')
}
});
});