-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
156 additions
and
43 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,16 +5,39 @@ | |
* @author John Martin [email protected] | ||
*/ | ||
|
||
modal = new ModalRemote('#ajaxCrubModal'); | ||
$(document).ready(function(){ | ||
|
||
// Create instance of Modal Remote | ||
// This instance will be controller all business logic of modal | ||
modal = new ModalRemote('#ajaxCrubModal'); | ||
|
||
// Catch click event of all button want to open modal | ||
$(document).on('click','[role="modal-remote"]',function(event){ | ||
event.preventDefault(); | ||
modal.remote(this,null); | ||
}); | ||
|
||
// Catch click event of all button want to open modal | ||
// with bulk action | ||
$(document).on('click','[role="modal-remote-bulk"]',function(event){ | ||
event.preventDefault(); | ||
|
||
var selectedIds = []; | ||
$('input:checkbox[name="selection[]"]').each(function () { | ||
if(this.checked) | ||
selectedIds.push($(this).val()); | ||
}); | ||
|
||
if(selectedIds.length==0){ | ||
modal.show(); | ||
modal.setTitle('Have no selection'); | ||
modal.setContent('You must select item for do this action'); | ||
modal.addButton("Close",'btn btn-default',function(button,event){ | ||
this.hide(); | ||
}); | ||
}else{ | ||
modal.remote(this,{pks:JSON.stringify(selectedIds)}); | ||
} | ||
}); | ||
|
||
$(document).on('click','[role="modal-remote"]',function(event){ | ||
if(event.preventDefault){ | ||
event.preventDefault(); // () was missing here | ||
} | ||
if (event.stopPropagation) { | ||
event.stopPropagation(); | ||
} | ||
modal.remote(this,function(){ | ||
$.pjax.reload({container:'#crud-datatable-pjax'}); | ||
}); | ||
}); |