Fixed select all bug after performing a search

This commit is contained in:
Kevin Crider 2013-09-29 13:59:19 -04:00
parent f8ea2a777c
commit de99655196
3 changed files with 11 additions and 35 deletions

View File

@ -50,7 +50,6 @@ unset($monitor);
</div> </div>
<?php echo $this->Form->end(array('label' => 'Search', 'class' => 'btn btn-default')); ?> <?php echo $this->Form->end(array('label' => 'Search', 'class' => 'btn btn-default')); ?>
<?php /*echo $this->Form->end(array('label' => 'Search', 'id' => 'EventsButtonSearch', 'class' => 'btn btn-default'));*/ ?>
<?php echo $this->Html->link('Delete Selected','#',array('class' => 'btn btn-default', 'onClick' => '$("#EventsDeleteSelectedForm").submit();')); ?> <?php echo $this->Html->link('Delete Selected','#',array('class' => 'btn btn-default', 'onClick' => '$("#EventsDeleteSelectedForm").submit();')); ?>
</div> </div>
@ -58,6 +57,7 @@ unset($monitor);
<?php $this->end(); ?> <?php $this->end(); ?>
<div id="EventsContent">
<ul class="pagination"> <ul class="pagination">
<?php echo $this->Paginator->numbers(array('tag' => 'li', 'separator' => false, 'currentClass' => 'active', 'currentTag' => 'span')); ?> <?php echo $this->Paginator->numbers(array('tag' => 'li', 'separator' => false, 'currentClass' => 'active', 'currentTag' => 'span')); ?>
</ul> </ul>
@ -67,9 +67,13 @@ unset($monitor);
?> ?>
<table class="table table-condensed table-striped" id="Events"> <table class="table table-condensed table-striped" id="Events">
<thead>
<?php <?php
echo $this->Html->tableHeaders(array($this->Form->checkbox('', array('hiddenField' => false, 'class' => 'selectAll')), 'Thumbnail', 'Id', 'Name', 'Monitor', 'Cause', 'Date/Time', 'Duration', 'Alarm Frames', 'Total Score', 'Avg. Score', 'Max Score')); echo $this->Html->tableHeaders(array($this->Form->checkbox('', array('hiddenField' => false, 'class' => 'selectAll')), 'Thumbnail', 'Id', 'Name', 'Monitor', 'Cause', 'Date/Time', 'Duration', 'Alarm Frames', 'Total Score', 'Avg. Score', 'Max Score'));
?>
</thead>
<tbody id="EventsTableBody">
<?
foreach ($events as $key => $value) { foreach ($events as $key => $value) {
echo $this->Html->tableCells(array( echo $this->Html->tableCells(array(
$this->Form->checkbox('delete.', array( $this->Form->checkbox('delete.', array(
@ -86,7 +90,6 @@ foreach ($events as $key => $value) {
$value['Event']['Name'], $value['Event']['Name'],
$value['Monitor']['Name'], $value['Monitor']['Name'],
$value['Event']['Cause'], $value['Event']['Cause'],
//$value['Event']['StartTime'],
$this->Time->format('n/j/y @ g:i:s A', $value['Event']['StartTime'], null, 'EST'), $this->Time->format('n/j/y @ g:i:s A', $value['Event']['StartTime'], null, 'EST'),
$value[0]['Duration'], $value[0]['Duration'],
$value['Event']['AlarmFrames'], $value['Event']['AlarmFrames'],
@ -96,6 +99,7 @@ foreach ($events as $key => $value) {
)); ));
} }
?> ?>
</tbody>
</table> </table>
<? <?
@ -105,23 +109,4 @@ foreach ($events as $key => $value) {
<ul class="pagination"> <ul class="pagination">
<?php echo $this->Paginator->numbers(array('tag' => 'li', 'separator' => false, 'currentClass' => 'active', 'currentTag' => 'span')); ?> <?php echo $this->Paginator->numbers(array('tag' => 'li', 'separator' => false, 'currentClass' => 'active', 'currentTag' => 'span')); ?>
</ul> </ul>
</div>
<?
/*
$data = $this->Js->get('#EventsIndexForm')->serializeForm(array('isForm' => true, 'inline' => true));
$this->Js->get('#EventsIndexForm')->event(
'submit',
$this->Js->request(
array('action' => 'index'),
array(
'update' => '#Events',
'data' => $data,
'async' => true,
'dataExpression' => true,
'method' => 'POST'
)
)
);
echo $this->Js->writeBuffer();
*/
?>

View File

@ -79,7 +79,7 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework
</div> </div>
</div> </div>
</div> </div>
<div class="col-sm-10 col-md-10 col-lg-10"> <div class="col-sm-10 col-md-10 col-lg-10" id="main-content-body">
<?php echo $this->Session->flash(); ?> <?php echo $this->Session->flash(); ?>
<?php echo $this->fetch('content'); ?> <?php echo $this->fetch('content'); ?>

View File

@ -90,16 +90,7 @@ $(document).ready(function() {
$("#EventsButtonSearch").button(); $("#EventsButtonSearch").button();
$('#EventsIndexForm').submit(function() { $('#EventsIndexForm').submit(function() {
//$('#EventsDeleteSelectedForm').load('/events/index #Events', $('#EventsIndexForm').serialize()); $('#main-content-body').load('/events/index #EventsContent', $('#EventsIndexForm').serialize());
var data = $('#EventsIndexForm').serialize();
$.ajax({
url: '/events/index',
data: data
}).done(function(data) {
var content = $(data).find('#Events');
console.log(content);
$('#EventsDeleteSelectedForm').html(content);
});
}); });
$( "#EventStartDate" ).datepicker({ $( "#EventStartDate" ).datepicker({
@ -176,7 +167,7 @@ $(document).ready(function() {
}); });
// Select All Events // // Select All Events //
$('input[type=checkbox].selectAll').click(function(e) { $('body').on('click', 'input[type=checkbox].selectAll', function() {
$(this).closest('table').find(':checkbox').prop('checked', this.checked); $(this).closest('table').find(':checkbox').prop('checked', this.checked);
}); });
// Select All Events // // Select All Events //