I am seeing a strange problem when using dhtmlxCombo with a Ruby on Rails application - it appears that the values from dhtmlxCombo controls are not “seen” by the Rails controller. However, I can see that the controls are being rendered with the correct name attributes using the Web Developer plugin for Firefox.
I suspect that this may be due to the Rails form processing logic expecting input tags to have both a name and an id attribute. From what I can see, the dhtmlxCombo controls get converted into <input type=“text” name="…" …> controls by manipulating the DOM. Is there a way to also set the id attribute to a unique value (i.e. something different than the name value)?
For example, if I did:
<div id="product_item" style="width:200px; height:30px;"></div>
...
var z2 = new dhtmlXCombo("product_item", "product[item]", 200);
z2.enableFilteringMode(true);
z2.loadXML("/products/items");
I need a way to have the resulting input control have the name “product[item]” but id “product_item” to make it look like a typical Rails-rendered form input.
I suppose I could hack it by calling some JS onSubmit that manipulated the DOM before posting the form, but that doesn’t seem like a very elegant solution.
Alexandra, thanks for the reply to my question! I tried it and successfully added the id, but I think I found a more basic problem. When I turn on HttpFox to watch the POST data being sent from my form, it doesn’t have any of the input fields added by dhtmlxCombo! I’m sure I’m missing something really simple. Any help is appreciated!
Also, for what it’s worth, I tried calling _confirmSelection() before submitting with no luck. I confirmed that the combo boxes are otherwise working - i.e. they populate values in the dropdown, etc.
Think the problem with returning the value of the combobox is down to the Prototype JS library element accessor ($), which requires an id - there was some talk on the forums about including a variation of getElementsByName accessor into Prototype but I think they decided that it would be too application specific.
This is the sort of Ajax control I’m using atm to return a value from a combobox, with the ‘getElementsByName’ inserted directly into the :with option (excuse the old version of the link_to_remote, the application is developed in Rails 2.2… just don’t ask…).
Think JQuery allows you to select elements by their attributes ( $(‘a[rel=“nofollow self”]’)), maybe try that JS library instead.
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan