Re: Cakephp Autocomplete Tutorial ajax error

2015-03-25 Thread Dario Espina
Check this: 
http://stackoverflow.com/questions/19911685/cakephp-trying-to-send-a-ajax-request/19938762#19938762

On Saturday, January 31, 2015 at 8:13:54 PM UTC-4, ajt wrote:
>
>
>
> In CakePHP, I am trying to create a autocomplete function from a textbox, 
> using this tutorial: http:
> //bakery.cakephp.org/articles/matt_1/2011/08/07/yet_another_jquery_autocomplete_helper_2
>
>
> I keep getting a
>
> Undefined index: autoCompleteText
>
>
> I solved the helper issue as it finds the helper as this is cakephp 1.X 
> code and I have 2.X
>
>
> controller - Tests
> function auto_complete
>
>
>
> class TestsController extends AppController {
>
> public $helpers = array('Html', 'Form', 'Session','Js','AutoComplete');
>
>  public function auto_complete() {
>  $this->loadModel('Tutor');
>  debug( $this->params);
>
>
> $terms = $this->Tutor->find('all', array(
> 'conditions' => array(
> 'Tutor.first_name LIKE' => 
> $this->params['url']['autoCompleteText'].'%'
> ),
> 'fields' => array('Tutor.first_name'),
> 'limit' => 3,
> 'recursive'=>-1,
> ));
> $terms = Set::Extract($terms,'{n}.Tutor.first_name');
> $this->set('terms', $terms);
> $this->layout = '';
> } 
>
>
>
> view
>  auto_complete.ctp
>
>
>  echo $this->AutoComplete->input(
> 'Tutor.first_name',
> array(
> 'autoCompleteUrl'=>$this->Html->url( 
> array(
> 'controller'=>'tests',
> 'action'=>'auto_complete',
> )
> ),
> 'autoCompleteRequestItem'=>'autoCompleteText',
> )
> );
>
>   if(isset($terms)) {
> echo $this->Js->object($terms);
>   }
>
>echo $this->Form->create('');
>
> echo $this->Form->input('type', array('label' => 'Choose' ));
>echo $this->Form->end('send'); 
>
>  ?>
>
>
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Cakephp Autocomplete Tutorial ajax error

2015-02-01 Thread euromark
It is best not to use the JS helper(s) etc.
Use just plain jQuery and it will work quite easily out of the box

See http://sandbox.dereuromark.de/sandbox/ajax_examples/ for live examples
mark


Am Sonntag, 1. Februar 2015 01:13:54 UTC+1 schrieb ajt:
>
>
>
> In CakePHP, I am trying to create a autocomplete function from a textbox, 
> using this tutorial: http:
> //bakery.cakephp.org/articles/matt_1/2011/08/07/yet_another_jquery_autocomplete_helper_2
>
>
> I keep getting a
>
> Undefined index: autoCompleteText
>
>
> I solved the helper issue as it finds the helper as this is cakephp 1.X 
> code and I have 2.X
>
>
> controller - Tests
> function auto_complete
>
>
>
> class TestsController extends AppController {
>
> public $helpers = array('Html', 'Form', 'Session','Js','AutoComplete');
>
>  public function auto_complete() {
>  $this->loadModel('Tutor');
>  debug( $this->params);
>
>
> $terms = $this->Tutor->find('all', array(
> 'conditions' => array(
> 'Tutor.first_name LIKE' => 
> $this->params['url']['autoCompleteText'].'%'
> ),
> 'fields' => array('Tutor.first_name'),
> 'limit' => 3,
> 'recursive'=>-1,
> ));
> $terms = Set::Extract($terms,'{n}.Tutor.first_name');
> $this->set('terms', $terms);
> $this->layout = '';
> } 
>
>
>
> view
>  auto_complete.ctp
>
>
>  echo $this->AutoComplete->input(
> 'Tutor.first_name',
> array(
> 'autoCompleteUrl'=>$this->Html->url( 
> array(
> 'controller'=>'tests',
> 'action'=>'auto_complete',
> )
> ),
> 'autoCompleteRequestItem'=>'autoCompleteText',
> )
> );
>
>   if(isset($terms)) {
> echo $this->Js->object($terms);
>   }
>
>echo $this->Form->create('');
>
> echo $this->Form->input('type', array('label' => 'Choose' ));
>echo $this->Form->end('send'); 
>
>  ?>
>
>
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Cakephp Autocomplete Tutorial ajax error

2015-01-31 Thread ajt




In CakePHP, I am trying to create a autocomplete function from a textbox, 
using this tutorial: http:
//bakery.cakephp.org/articles/matt_1/2011/08/07/yet_another_jquery_autocomplete_helper_2


I keep getting a

Undefined index: autoCompleteText


I solved the helper issue as it finds the helper as this is cakephp 1.X 
code and I have 2.X


controller - Tests
function auto_complete



class TestsController extends AppController {

public $helpers = array('Html', 'Form', 'Session','Js','AutoComplete');

 public function auto_complete() {
 $this->loadModel('Tutor');
 debug( $this->params);


$terms = $this->Tutor->find('all', array(
'conditions' => array(
'Tutor.first_name LIKE' => 
$this->params['url']['autoCompleteText'].'%'
),
'fields' => array('Tutor.first_name'),
'limit' => 3,
'recursive'=>-1,
));
$terms = Set::Extract($terms,'{n}.Tutor.first_name');
$this->set('terms', $terms);
$this->layout = '';
} 



view
 auto_complete.ctp


AutoComplete->input(
'Tutor.first_name',
array(
'autoCompleteUrl'=>$this->Html->url( 
array(
'controller'=>'tests',
'action'=>'auto_complete',
)
),
'autoCompleteRequestItem'=>'autoCompleteText',
)
);

  if(isset($terms)) {
echo $this->Js->object($terms);
  }

   echo $this->Form->create('');

echo $this->Form->input('type', array('label' => 'Choose' ));
   echo $this->Form->end('send'); 

 ?>



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


CakePHP autocomplete tutorial ajax error

2015-01-31 Thread ajt


Hi,

In CakePHP, I am trying to create a autocomplete function from a textbox, 
using this tutorial: 
http://bakery.cakephp.org/articles/matt_1/2011/08/07/yet_another_jquery_autocomplete_helper_2

I keep getting a Error: AutoCompleteHelper could not be found. Undefined 
index: autoCompleteText

I am unsure how to fix this as I have tried relocating the files and still 
the same error.

I create the below files and copy the code from the tutorial, create the 
auto_complete.php in the view/helpers directory, and create 
webroot/js/views/helpers/auto_complete.js.

controller - Tests function auto_complete

class TestsController extends AppController {

public $helpers = array('Html', 'Form', 'Session','Js','AutoComplete');

 public function auto_complete() {
 $this->loadModel('Tutor');
 debug( $this->params);


$terms = $this->Tutor->find('all', array(
'conditions' => array(
'Tutor.first_name LIKE' => 
$this->params['url']['autoCompleteText'].'%'
),
'fields' => array('Tutor.first_name'),
'limit' => 3,
'recursive'=>-1,
));
$terms = Set::Extract($terms,'{n}.Tutor.first_name');
$this->set('terms', $terms);
$this->layout = '';
} 



view
 auto_complete.ctp


AutoComplete->input(
'Tutor.first_name',
array(
'autoCompleteUrl'=>$this->Html->url( 
array(
'controller'=>'tests',
'action'=>'auto_complete',
)
),
'autoCompleteRequestItem'=>'autoCompleteText',
)
);

  if(isset($terms)) {
echo $this->Js->object($terms);
  }

   echo $this->Form->create('');

echo $this->Form->input('type', array('label' => 'Choose' ));
   echo $this->Form->end('send'); 

 ?>




-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.