This file contains hidden or 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
public function delete($id = null) { | |
if ($this->request->is('ajax')) { | |
$this->autoRender = false; | |
$this->layout = null; | |
$response = array(); | |
$cur_date = date("Y-m-d H:i:s"); | |
$this->request->data['User']['is_deleted']=1; | |
$this->request->data['User']['is_active']=0; | |
$this->request->data['User']['date_deleted']=$cur_date; |
This file contains hidden or 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
$(document).ready(function() { | |
$('a.delete').click(function(e) { | |
var __this = this; | |
e.preventDefault(); | |
var parent = $(this).parent("td").parent("tr"); | |
$.ajax({ | |
type: 'get', | |
url: $(__this).attr("href"), | |
dataType: 'json', | |
beforeSend: function() { |
This file contains hidden or 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
public function delete($id = null) { | |
if($this->request->is('ajax')) { | |
//$this->layout = 'ajax'; | |
$response = 'Fail'; | |
if ($this->User->delete($id)) { | |
$response= 'OK'; | |
} | |
$this->set('response', $response); | |
} | |
} |
This file contains hidden or 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
$(document).ready(function() { | |
$('a.delete').click(function(e) { | |
var __this = this; | |
e.preventDefault(); | |
var parent = $(this).parent("td").parent("tr"); | |
$.ajax({ | |
type: 'get', | |
url: $(__this).attr("href"), | |
beforeSend: function() { | |
parent.animate({'backgroundColor':'#fb6c6c'},300); |
This file contains hidden or 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
public function delete($id = null) { | |
if($this->request->is('ajax')) { | |
//$this->autoRender = false; | |
if ($this->User->delete($id)) { | |
$response = $this->Session->setFlash(__('User deleted')); | |
$response .= $this->redirect(array('action' => 'index')); | |
} else { | |
$response = $this->Session->setFlash(__('User was not deleted')); | |
$response.= $this->redirect(array('action' => 'index')); | |
} |
This file contains hidden or 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
<?php | |
App::uses('AppController', 'Controller'); | |
class CountriesController extends AppController { | |
public $helpers = array('Js'); | |
public $components = array('RequestHandler'); | |
public function select() { | |
$countries = $this->Country->find('list'); |
This file contains hidden or 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
//Controller Action | |
public function find() { | |
if ($this->request->is('ajax')) { | |
$this->autoRender = false; | |
$country_name = $this->request->query('term'); | |
$results = $this->Country->find('all', array( | |
'conditions' => array('Country.name LIKE ' => '%' . $country_name . '%') |
This file contains hidden or 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
<?php | |
echo $this->Form->create('Country', array('action' => 'find')); | |
echo $this->Form->input('name',array('id' => 'Autocomplete')); | |
echo $this->Form->submit(); | |
echo $this->Form->end(); | |
?> | |
<script type="text/javascript"> | |
$(document).ready(function($){ | |
$('#Autocomplete').autocomplete({ | |
source:'<?= $this->Html->url(array("controller" => "countries","action"=> "find")); ?>', |
This file contains hidden or 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
public function find() { | |
if ($this->request->is('ajax')) { | |
$this->autoRender = false; | |
$country_name = $this->request->data['Country']['name']; | |
$results = $this->Country->find('all', array( | |
'conditions' => array('Country.name LIKE ' => '%' . $country_name . '%'), | |
'recursive' => -1 | |
)); |
This file contains hidden or 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
<?php | |
echo $this->Form->create('Country', array('action' => 'find')); | |
echo $this->Form->input('name',array('id' => 'Autocomplete')); | |
echo $this->Form->submit(); | |
echo $this->Form->end(); | |
?> | |
<script type="text/javascript"> | |
$(document).ready(function($){ | |
$('#Autocomplete').autocomplete({ | |
source:'<?php=$this->Html->url(array("controller" => "countries","action"=> "find")); ?>',, |