:id_element attribute not working #69

Closed
leobossmann opened this Issue Jul 14, 2011 · 11 comments

Comments

Projects
None yet
5 participants
@leobossmann
Contributor

leobossmann commented Jul 14, 2011

Hi,

first of all thanks for the gem, it works like a charm, I just have one (hopefully minor) issue.

I have managed to succesfully integrate an autocomplete text field. It works so far and pulls the right data. I want to update a hidden field with the id it pulls from the database and that is exactly where the problem is:

In my form I have the following:

f.autocomplete_field :customer_name, autocomplete_customer_last_name_purchase_orders_path, :id_element => '#purchase_order_customer_id'

purchase_order_customer_id is a normal text field, which should, by my understanding, be updated with the id value of the option I selected in the autocomplete dropdown.

It renders as:
<input data-autocomplete="/purchase_orders/autocomplete_customer_last_name" id="purchase_order_customer_name" id_element="#purchase_order_customer_id" name="purchase_order[customer_name]" size="30" type="text" />
The :id_element attribute gets rendered as normal HTML attribute, therefore the update does not work.

Shouldn't it be rendered as something like data-id-element ="#purchase_order_customer_id' in order to work?

Or am I missing something here? I tried to follow the readme as closely as possible, please bear with me If I'm asking stupid questions, this is my first rails project…

Thanks in Advance

Leo

@leobossmann

This comment has been minimized.

Show comment Hide comment
@leobossmann

leobossmann Jul 14, 2011

Contributor

…nevermind, it works, seems some misconfiguration on my side caused it.

Contributor

leobossmann commented Jul 14, 2011

…nevermind, it works, seems some misconfiguration on my side caused it.

@nicholaspufal

This comment has been minimized.

Show comment Hide comment
@nicholaspufal

nicholaspufal Jul 19, 2011

What you did to solve that? Here the field always displays 0 (can see it on the server log, when I submit it).

What you did to solve that? Here the field always displays 0 (can see it on the server log, when I submit it).

@leobossmann

This comment has been minimized.

Show comment Hide comment
@leobossmann

leobossmann Jul 21, 2011

Contributor

That is the strange thing about it, I have no idea. I wrote the ticket above and suddenly it worked. I changed absolutely nothing.That's why I suspect that my configuration is somewhat flawed, I use a Rails Turnkey Linux, maybe that's the culprit…

Contributor

leobossmann commented Jul 21, 2011

That is the strange thing about it, I have no idea. I wrote the ticket above and suddenly it worked. I changed absolutely nothing.That's why I suspect that my configuration is somewhat flawed, I use a Rails Turnkey Linux, maybe that's the culprit…

@nicholaspufal

This comment has been minimized.

Show comment Hide comment
@nicholaspufal

nicholaspufal Jul 21, 2011

Thanks for the reply.

But my guess is that you assertion is true. It should be "data-id-element" => this is HTML5 compatible. "id_element" isn't.

I did solve it here by using :update_elements instead of :id_elements. That way worked fine.

Did create another issue with that info:

#75

Just in case you or any other need that reference ;)

Thanks for the reply.

But my guess is that you assertion is true. It should be "data-id-element" => this is HTML5 compatible. "id_element" isn't.

I did solve it here by using :update_elements instead of :id_elements. That way worked fine.

Did create another issue with that info:

#75

Just in case you or any other need that reference ;)

@andreteves

This comment has been minimized.

Show comment Hide comment
@andreteves

andreteves Jul 21, 2011

I tried "update_elements" but it didn't work for me, I get an error with JSON.generate (maybe because I'm using json_pure as default encoder). Any help?

However, this commit fixed my problem with id_element not rendering "data-id-element":

https://github.com/andreteves/rails3-jquery-autocomplete/blob/master/lib/rails3-jquery-autocomplete/form_helper.rb

I tried "update_elements" but it didn't work for me, I get an error with JSON.generate (maybe because I'm using json_pure as default encoder). Any help?

However, this commit fixed my problem with id_element not rendering "data-id-element":

https://github.com/andreteves/rails3-jquery-autocomplete/blob/master/lib/rails3-jquery-autocomplete/form_helper.rb

@sandrods

This comment has been minimized.

Show comment Hide comment
@sandrods

sandrods Jul 21, 2011

I don't think this issue should be closed.
The expected beahviour does not work. The commit above should be incorporated in the gem, don't you think?

I don't think this issue should be closed.
The expected beahviour does not work. The commit above should be incorporated in the gem, don't you think?

@leobossmann leobossmann reopened this Jul 21, 2011

@leobossmann

This comment has been minimized.

Show comment Hide comment
@leobossmann

leobossmann Jul 21, 2011

Contributor

I agree, I just tried it on a different machine, with the same results as above. Gonna try again tomorrow and will post the results.

Contributor

leobossmann commented Jul 21, 2011

I agree, I just tried it on a different machine, with the same results as above. Gonna try again tomorrow and will post the results.

@leobossmann

This comment has been minimized.

Show comment Hide comment
@leobossmann

leobossmann Jul 22, 2011

Contributor

@andreteves, your commit fixed the problem for me, thanks a lot!
@nicholaspufal, I tried the :update_elements thing, it resulted in a JSON Error as well, however I didn't use the autocomplete_field_tag, maybe that's the problem…

Contributor

leobossmann commented Jul 22, 2011

@andreteves, your commit fixed the problem for me, thanks a lot!
@nicholaspufal, I tried the :update_elements thing, it resulted in a JSON Error as well, however I didn't use the autocomplete_field_tag, maybe that's the problem…

@leobossmann

This comment has been minimized.

Show comment Hide comment
@leobossmann

leobossmann Jul 23, 2011

Contributor

@andreteves, I have have issued a pull request with your fix, is that alright with you?

Contributor

leobossmann commented Jul 23, 2011

@andreteves, I have have issued a pull request with your fix, is that alright with you?

@andreteves

This comment has been minimized.

Show comment Hide comment
@andreteves

andreteves Jul 23, 2011

Sure!

Sure!

juniorz added a commit to juniorz/rails3-jquery-autocomplete that referenced this issue Jul 28, 2011

dabit added a commit that referenced this issue Aug 8, 2011

Merge pull request #77 from leobossmann/master
fix for issue #69, :id_element attribute not working
@dabit

This comment has been minimized.

Show comment Hide comment
@dabit

dabit Aug 8, 2011

Contributor

Merged and released as 0.9.1

Contributor

dabit commented Aug 8, 2011

Merged and released as 0.9.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment