Offering small 30 USD bounty to come up with a fix for a bug with the jquery_autocomplete module.
The jquery_autocomplete module is a simple module that uses JavaScript to remove the [nid:X] text when you select an item in a Node Reference field.
For example, if you have My Node Title [nid:384] in the input, jquery_autocomplete changes it to just My Node Title.
The module is very small and does not yet have a project page, you will find it here : http://drupal.org/node/640832, a page that contains 2 versions of the module:
- A first version (comment #10 - http://drupal.org/node/640832#comment-4112374) : Works perfectly in IE and Firefox, but doesn't work in Chrome,
- A second version (comment #29 - http://drupal.org/node/640832#comment-4750072) : Contains a quick fix for Chrome issue, which sadly causes 2 bugs:
- If there are multiple nodereference fields on the form, all these fields are filled in with the selected value
- It does not work with nodereference fields that may accept multiple values
So the fix should simply get this module to work:
- with "simple value" and "multiple values" nodereference fields
- with multiple nodereference fields present on a same form
- with firefox, IE and Chrome.
I suspect it might be a simple fix, but I am not skilled with jQuery or JavaScript. Payment is via PayPal only, payable once the fix is complete.
I want to open up this bounty to anyone, so please just post here if you are working on it so others can be aware it is already being worked on.
NB : What I've already come up with :
Using the code from #29, I managed to partially "fix" the first bug, replacing :
var ac = $('input.form-autocomplete[type="text"]'); (=> this is why all fields with this class are filled in...)
by
var ac = $(this.input);
so only the current input is filled in. However, this little "fix doesn't work with "multiple values" fields, which are completely broken: adding a second item rewrites the [nid:xxx] bit in the first item, and removes autocomplete function in the second one...
Comments
Each time this issue
Each time this issue surfaces, I keep offering an alternative (non-JavaScript) solution: http://right-here-tavern.info/drave-robber/micromodules-need-no-nid
Limitations: in case of duplicate titles, always picks the first.
If this serves your case to the level of "almost, but", I'm ready to look into bringing it to complete perfection. :)
Hi, thanks for your answer. I
Hi, thanks for your answer.
I already looked at what you posted here about that: http://drupal.org/node/1220028, and the related threads.
It is a nice alternative, but I can't do it as I have a lot of nodes with identical titles, so the current hack won't work.
But I'm not against a hack of nodereference module as I don't have the "maintenance issue". So if you find out how to get it to work with identical titles too, I would be happy to test it.
If you have lots of nodes
If you have lots of nodes with identical titles, what is your rationale for removing an unique identifier (nid) then?
Would you like it to be replaced with something else, e.g., node creation date/time?
I wrote v1.1, which makes
I wrote v1.1, which makes duplicate titles unique by adding trailing spaces; visually they will be the same, but this is pretty fragile however – deleting a trailing space would change the reference, adding too much would simply remove it.
http://right-here-tavern.info/sites/default/files/dr_neednonid_1.1.tar.gz
The idea of putting something
The idea of putting something else inside the [] is not bad, you already mentioned it in the other thread. But we would have to do it only for specific inputs/fields, and that makes too much hacking of the core module, I'm not sure we would understand all the consequences.
Regarding you patch, and as you mention, it is very fragile, we would like something more robust.
So we are currently investing how we could have no duplicate titles, in order to use your first hack solution.
We will get back to you if that's what we're choosing. Meanwhile, we still welcome JS fixes of the jquery_autocomplete module, which is the most flexible solution. Thanks again for your help!
Excusez-moi, this module does
Excusez-moi, this module does not require you to hack anything. It's a completely legit override.
The reason it was being called a 'hack' was because hacking was the initial solution proposed in that old thread, and that was, well, three months ago. Some progress has been made since then. :)
All apologies, I surely used
All apologies, I surely used the wrong words, but my english is not perfect... far from that!
But when I see "This module is evil. Use it with caution." on your page, I feel not so confident using it, even if it's probably very good. It's just that I don't know drupal enough to understand all the implications.
Is there a difference (apart from the opposition hack/module) between the 2 lines hack (here it is!) that you propose here: http://drupal.org/node/1220028#comment-4740858 and your module (before the trailing space version? Which one is "safer"?
I wrote a faq.txt for the
I wrote a faq.txt for the module – hope it clarifies things a bit.
Thanks, it's much clearer now
Thanks, it's much clearer now indeed.
I'll stick with the core 2 lines nodereference hack then - it replaces quite a lot of code as you say, and we're using modules such as Noderelationships which also alter these fields, plus a custom "edit forms" module that modify forms further.
But first I would like to see if there is absolutely no way to get this jquery_autocomplete module to work... Otherwise I get back to you to tell you how your solution works out in our configuration.
Did you have any other
Did you have any other changes you had made to the code besides the one above? That single change seemed to work for me as I was debugging through this code. I came up with the same solution as you did.
NVM: Found the issue you're describing. I had user autocomplete on the form as the second field, not another nodereference. Looking at it now.
So your fix did seem to do
So your fix did seem to do what you are looking for. Line 38 should be
var ac = $(this.input);and as long as their are no other changes it seems to work.Validated in Chrome, Firefox, and IE.
There is still a bug with mutiple values fields
Hi, thanks for your answer.
This quick fix doesn't work for me. On a nodereference field that accept multiple values, when clicking on "Add another item", it rewrites the [nid:xxx] bit in the first item, and removes autocomplete function in the second one... I also just found out that if I try to use again a "simple value" nodereference field after that, the suggestion popup doesn't hide anymore.
Can you see this bug too?
You said "Found the issue you're describing. I had user autocomplete on the form as the second field, not another nodereference." => Did you solve this?
Haven't actually try if the
Haven't actually try if the following js is working, but seems that we can merge all the $() calling into a single calls / looping. may need to test this though
--------------------------------------------------------------------------------------------------------
if you can use drupal why use others?
VicTheme.com
Hi duckzland, thanks for your
Hi duckzland, thanks for your answer.
I tested this but I get the same bugs as described above (pb with multiple values fields), +1 : the suggestions popups don't close.
Tried to add the var ac = $(this.input); line too, but I get the same results.
fix
just add check if "form-autocomplete" exist on this page
Hi, Thanks for your answer.
Hi,
Thanks for your answer. Actually, the bounty has already been given and I totally forgot to mention it here, apologies for that.
We are going to create a project page dedicated to this module as it has been futher improved (it does not only contain a JS file anymore. By the way, it also includes the fix you proposed here, rightfully spotted !)
I will post the link here as soon as it is created.
Here is the link to the
Here is the link to the project page : http://drupal.org/project/nodereference_nid_trim