Yii Framework Forum: CAutoComplete is not working in IE - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CAutoComplete is not working in IE Rate Topic: -----

#1 User is offline   bas_vdl 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 215
  • Joined: 01-April 09

Posted 22 January 2010 - 08:05 AM

When i open one of my items with the tag playground.

The value of the autocomplete textfield in my form will be "playground, " (without quotes). When i type swimmingpool and select that one from the auto complete list the value of the field will change to: "swimmingpool, swim, " instead of "playground, swimmingpool, ".

In FireFox this is working perfect...

<?php 
$optionsTag = array(
    'name' => 'Daytrip[Tags]',
    'url' => array('tag/autocompletetag'), 
    'max' => 10,
    'minChars' => 2, 
    'delay' => 500,
    'matchCase' => false,
    'multiple' => true,
    'value' => ('' != $daytrip->Tags) ? $daytrip->Tags . ', ' : '',
);
$this->widget('CAutoComplete', $optionsTag);
?>

0

#2 User is offline   nmunro 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 20-January 10

Posted 22 March 2010 - 05:46 AM

I am having the same problem - anyone found a solution?

I also tried upgrading to 1.1.1 and now autocomplete doesn't work at all. It doesn't even try to do AJAX or give any JS errors in either IE or Firefox - its simply does nothing (tried deleting the assets folders in case it was a cache issue).

$this->widget('CAutoComplete', array(
  'model'=>$model,
  'attribute'=>'features',
  'url'=>array('suggestFeatures'),
  'multiple'=>true,
  'htmlOptions'=>array('size'=>50),
));

0

#3 User is offline   nmunro 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 20-January 10

Posted 22 March 2010 - 06:07 AM

With 1.1.0, IE does actually work if you select the option from the suggested list using the up/down keys, but if you select using the MOUSE, it screws up - the new selection overwrites the first and leaves the typed characters at the end. Maybe some issue with the cursor position being changed to the start of the text box when you click the menu?

Regarding 1.1.1, I saw the other messsage about the conflict between Jui, so I assume that is why it doesn't work at all. I agree about using an RC for JQuery and although I have read the note about using clientScript->scriptMap, I have to say that it is not very clear to me how to do this: could someone give an exact example of how to force it to use the old version?

Thanks!
0

#4 User is offline   outrage 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 313
  • Joined: 10-November 09
  • Location:Blackpool, United Kingdom

Posted 22 March 2010 - 01:28 PM

View Postnmunro, on 22 March 2010 - 05:46 AM, said:

I am having the same problem - anyone found a solution?

I also tried upgrading to 1.1.1 and now autocomplete doesn't work at all. It doesn't even try to do AJAX or give any JS errors in either IE or Firefox - its simply does nothing (tried deleting the assets folders in case it was a cache issue).

$this->widget('CAutoComplete', array(
  'model'=>$model,
  'attribute'=>'features',
  'url'=>array('suggestFeatures'),
  'multiple'=>true,
  'htmlOptions'=>array('size'=>50),
));




I have used CAutoComplete in a couple of recent projects with no problem in IE.

Here is a working controller action for review if needed:

public function actionAutoCompleteLookup()
        {
           if(Yii::app()->request->isAjaxRequest && isset($_GET['q']))
           {

              /* q is the default GET variable name that is used by
              / the autocomplete widget to pass in user input
              */
              $name = $_GET['q'];
              // this was set with the "max" attribute of the CAutoComplete widget
              $limit = min($_GET['limit'], 50);
              $criteria = new CDbCriteria;
              $criteria->select = "city";
              $criteria->distinct=true;       
              $criteria->condition = "city LIKE :sterm";
              $criteria->params = array(":sterm"=>"$name%");
              //$criteria->order = "city";
              $criteria->limit = $limit;
              $resultArray = geocity::model()->findAll($criteria);
              $returnVal = '';
              foreach($resultArray as $result)
              {
                 $returnVal .= $result->getAttribute('city'). "\n";
              }
              echo $returnVal;
           }
        }


What is in your controller?
0

#5 User is offline   nmunro 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 20-January 10

Posted 22 March 2010 - 02:02 PM

Thanks, but I don't think the controller is the issue - as I say it works perfectly with FF and it also happens with the Yii Blog Demo (which is where I copied the code from!). It always happens with Vista/W7+IE8 if you select using the mouse (rather than the arrow keys).
0

#6 User is offline   outrage 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 313
  • Joined: 10-November 09
  • Location:Blackpool, United Kingdom

Posted 22 March 2010 - 02:23 PM

View Postnmunro, on 22 March 2010 - 02:02 PM, said:

Thanks, but I don't think the controller is the issue - as I say it works perfectly with FF and it also happens with the Yii Blog Demo (which is where I copied the code from!). It always happens with Vista/W7+IE8 if you select using the mouse (rather than the arrow keys).


Hmm, I have W7+IE8 and it works fine for me.

Try this app I started work on some time ago (just proof of concept - currently on the shelf).

EDIT: removed link.

Select a country, type in a business type ('plumber' perhaps) and then a city/town (auto complete part).
Does it work for you?
0

#7 User is offline   nmunro 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 20-January 10

Posted 22 March 2010 - 02:33 PM

Your one only allows a single choice - perhaps I didn't explain that. This issue only happens with multiple selections - the 1st is always fine, but try adding a comma and a 2nd entry using the mouse...

(here: http://www.yiiframew...com/demos/blog/ add a new post and then try adding multiple tags)

This post has been edited by nmunro: 22 March 2010 - 02:41 PM

0

#8 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,778
  • Joined: 17-January 09
  • Location:Russia

Posted 22 March 2010 - 02:34 PM

outrage
Your jQuery is 1.3.2 so it's probably being taken from assets that were set with previous version of Yii.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#9 User is offline   outrage 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 313
  • Joined: 10-November 09
  • Location:Blackpool, United Kingdom

Posted 22 March 2010 - 02:47 PM

View Postsamdark, on 22 March 2010 - 02:34 PM, said:

outrage
Your jQuery is 1.3.2 so it's probably being taken from assets that were set with previous version of Yii.


Hi Samdark,

You're right, this was done some time ago but I'm working on another project with similar auto-complete on town/city - using only the latest Yii 1.1.1 and again it works fine in IE.
0

#10 User is offline   nmunro 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 20-January 10

Posted 22 March 2010 - 02:51 PM

Add a new post and then try adding multiple tags selecting from the menu with the mouse:

http://www.yiiframew...com/demos/blog/
0

#11 User is offline   outrage 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 313
  • Joined: 10-November 09
  • Location:Blackpool, United Kingdom

Posted 22 March 2010 - 02:52 PM

View Postnmunro, on 22 March 2010 - 02:33 PM, said:

Your one only allows a single choice - perhaps I didn't explain that. This issue only happens with multiple selections - the 1st is always fine, but try adding a comma and a 2nd entry using the mouse...

(here: http://www.yiiframew...com/demos/blog/ add a new post and then try adding multiple tags)


I see what you mean now :)
0

#12 User is offline   outrage 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 313
  • Joined: 10-November 09
  • Location:Blackpool, United Kingdom

Posted 22 March 2010 - 03:40 PM

This seems to be a jQuery bug:

Official example page: http://jquery.bassis.../demo/json.html
0

#13 User is offline   outrage 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 313
  • Joined: 10-November 09
  • Location:Blackpool, United Kingdom

Posted 22 March 2010 - 03:58 PM

OK, this can be fixed but it's a bit of a hack.

Edit /framework/web/js/source/jquery.autocomplete.js

At line 221, comment out 'return false;' like so - //return false;

Save the file.

Delete contents of assets folder (cache).

Refresh.

Voila :)
0

#14 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,778
  • Joined: 17-January 09
  • Location:Russia

Posted 22 March 2010 - 05:01 PM

Are there any side effects?
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#15 User is offline   outrage 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 313
  • Joined: 10-November 09
  • Location:Blackpool, United Kingdom

Posted 22 March 2010 - 05:11 PM

View Postsamdark, on 22 March 2010 - 05:01 PM, said:

Are there any side effects?


Only one that I can see.
It has the benefit of placing the cursor at the end of the line, instead of the beginning :)
It seems to works fine now in both FF & IE, not tried other browsers.
0

#16 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,778
  • Joined: 17-January 09
  • Location:Russia

Posted 22 March 2010 - 05:14 PM

Well, placing cursor at the beginning of line should be quite irritating if we have multiple tags enabled.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#17 User is offline   nmunro 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 20-January 10

Posted 23 March 2010 - 05:25 AM

View Postoutrage, on 22 March 2010 - 03:40 PM, said:

This seems to be a jQuery bug:

Official example page: http://jquery.bassis.../demo/json.html


Thanks for your help. Have you reported this as a bug to them? There is a TODO comment in the code (Line 226) about cursor positioning, so perhaps this is related.

// TODO this should set the cursor to the right position, but it gets overriden somewhere
//$.Autocompleter.Selection(input, progress + seperator, progress + seperator);

0

#18 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,778
  • Joined: 17-January 09
  • Location:Russia

Posted 23 March 2010 - 07:09 AM

Jörn Zaefferer is not going to support standalone version anymore but is accepting patches.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#19 User is offline   lightglitch 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 33
  • Joined: 05-January 10

Posted 25 March 2010 - 11:37 AM

View Postnmunro, on 22 March 2010 - 05:46 AM, said:

I also tried upgrading to 1.1.1 and now autocomplete doesn't work at all. It doesn't even try to do AJAX or give any JS errors in either IE or Firefox - its simply does nothing (tried deleting the assets folders in case it was a cache issue).


Here is a patch for 1.1.1:

http://code.google.c.../detail?id=1048
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users