wuyuntao / jquery-autosuggest

A fork of AutoSuggest jQuery plugin writtern by Drew Wilson.
http://github.com/wuyuntao/jquery-autosuggest
118 stars 59 forks source link

value attribute is not populated with real value. #31

Open vikas-github opened 11 years ago

vikas-github commented 11 years ago

when I select element with value "1", value attribute of input.as-values is populated with "1," when I remove this element and select another element with value "2", this value is getting appended to previous value and value of input.as-values becomes "1,2," where it should delete the value "1,", but it still has it.

how to solve this problem? i want the id of the selected element at the server side. pls help

Pharserror commented 11 years ago

Bump. I am having this same problem. I am not the best at JavaScript nor did I spend much time looking at jquery.autosuggest.js but I cannot find anywhere in the code that there is a function for removal of an item (one that would essentially fix this problem). There are definitely add_selected_item and moveSelection but no remove_item or something similar. Perhaps we will need to code this ourselves?

Pharserror commented 11 years ago

I found this code but it is obviously not working or this issue would not have been experienced by multiple users.

var close = $('×').click(function(){ if(!is_new_value){ values_input.val(values_input.val().replace(","+data[opts.selectedValuesProp]+",",",")); } else { $('input[value='+data[opts.selectedValuesProp]+']').remove(); } opts.selectionRemoved.call(this, item); input_focus = true; input.focus(); return false; });

Perhaps the selection is not being made properly by using data[opts.selectedValuesProp]?

knalli commented 11 years ago

If you want, I'd put some time into a reworked fork at https://github.com/hlsolutions/jquery-autosuggest

Pharserror commented 11 years ago

I was thinking there was a newer fork. Is the issue solved in this one?

knalli commented 11 years ago

Should be: https://github.com/hlsolutions/jquery-autosuggest/blob/master/test/jquery.autoSuggest_test.js#L327

Pharserror commented 11 years ago

Is there a way to restore the old functionality where it would name the parameter sets something like "set_projects" or "set_customers"? I have specifically named sets in my code that I'm trying to grab and this randomly generated "as_values_xx" thing won't work. I'm sure there has been an issue generated on this that you may know about? I'll check out the issues section after this, just curious if you already know of one.

Pharserror commented 11 years ago

Found it. https://github.com/hlsolutions/jquery-autosuggest/commit/71a896153885fe6dd46e13c05f86964ae6eaff60