A RelationChoice widget in my custom type works fine until collective.js.jqueryui autocomplete
is enabled and then it stops working ie stops doing relation lookups; nothing happens when you type in the field.
(In another part of the site I use collective.js.jqueryui autocomplete
with Google Maps API to return address suggestions as the user completes an address field.)
The current workaround is to disable collective.js.jqueryui autocomplete
when i want to use the RelationChoice widget (and re-enable afterwards). Not a good solution.
Independantly:
plone.formwidget.autocomplete/jquery.autocomplete.min.js
my Google maps lookup doesnt fire (see code below) but the RelationChoice widget workscollective.js.jqueryui autocomplete
my Google maps lookup works but the RelationChoice widget doesnt fireCode sample:
$(document).ready(function() {
initialize();
$(function() { // Google maps lookup
$("#address").autocomplete({
//This bit uses the geocoder to fetch address values
source: function(request, response) {
geocoder.geocode( {'address': request.term}, function(results, status) { ...
... <input type="text" name="address" id="address" autocomplete="off" class="ac_input">
Is it possible I could re-use plone.formwidget.autocomplete/jquery.autocomplete.min.js
in the above code instead? I don't know how to get it to fire my Google maps lookup...? (collective.js.jqueryui autocomplete
successfully activates the above function when enabled.)
OK, I have done It. At least on Plone 4.3
The first part was, to fully enable the jQuery ui effects in the package. There is a namespace problem and a missing file, that results in .effects() is not a function
.
First, download the correct jQueryUI version cd into it and
jquery=/buildout_dir/parts/omelette/collective/js/jqueryui
cp jquery.ui.effect.min.js $jquery/js/jquery.ui.effect.core.min.js
then cd into the $jquery
directory and convert all effect packages to correct namespace. Eg:
mv js/jquery.ui.effect-highlight.min.js js/jquery.ui.effect.highlight.min.js
Then replace all occurrences of effects
with effect
$jquery/config.py
. In vim use
:1,$s/effects/effect/g
Secondly, to enable the jQuery based autocomplete widget, cd into the src directory of your buildout and
git clone https://github.com/plone/plone.formwidget.autocomplete.git plone.formwidget.autocomplete
git checkout jqueryui-autocomplete
then edit your versions.cfg
. For me
plone.formwidget.autocomplete >= 2.0
works. Then edit your buildout.cfg
and add the package under zcml
and develop
. I did a buildout, but it may be enough to restart Zope. The last step is obviously, to visit the portal installer and reinstall the product.
Update
As described in the comments, it was not fully functional. I further had to modify one .js file, namely autocomplete.js
from the plone.formwidget.autocomplete
package. Here is the result
This all together makes the RelationChoiceWidget and the AutocompleteWidget work together in one form. I like it.
I also filed a bug report on github for the jQueryUI package.