Login Register

ComboBox html mode

Has anyone used the html mode with the ComboBox widget? When I set mode to "remote" and return a JSON object, it works great but I can't seem to get it working with mode="html".

Is html mode valid in version 0.4.3 or am I running in circles?? If it is valid, does anyone have a code snippet?

I've never seen it work. I

I've never seen it work. I am thinking about implementing something to do so, but have no timeframe set. It would probably be an Input, that responded to normal input events, and provided a scrollable dropdown container. you would just add content, and each top-level child of the container would have some "value" ...

Combo Box

I have never used Combo box.
Its better if you provide some more information regarding combo box.
Also the plus point should be mentioned in points.
========================================================
Harry
WideCircles

Got it to work... kind of...

So I took one of the demo samples and tweaked it to run in html mode. First of all, I couldn't get any of the tests to run in IE7. Not sure why and don't really care at this point. But I did get it to work in Firefox. Here is what I've observed so far about the dataUrl source file:

1. If you put in plain text with no tags, it will not work.
Example:

hello world

2. If you put in one pair of tags, it will work.
Example:

hello world

3. If you put in more than one pair of tags, it will not work!
Examples:

hello world
how are you

or

hello world how are you

This last example completely destroys the point of even having an html mode in my opinion. Very disappointing!

More info...

After some further digging, it looks like regardless of the mode, at some point the Ajax magic that happens when calling the dojo.io.bind method is always using a text/json mimetype! When I try to change the mimetype to plain text, my html gets parsed and each individual character gets inserted as a separate row!

Back to the drawing board...

Success...

The whole purpose of trying to get the html mode working was to be able to highlight the search string in the results. For example, if the user types "al" into the list of states ComboBox, the drop down would highlight the first two letters of "Alabama" and "Alaska". I could not get the html mode to work and doing so looked like it would take too much time and effort. So instead I hacked the way the dropdown list is displayed (in ComboBox.js) to change the search string substring in the results to a bold typeface. Here's the first draft - it's very basic:

Line 403:

if (tr) {
   var val = tr[0].toLowerCase();
   var str = this.textInputNode.value;
   var i = val.indexOf(str);
   var td = document.createElement("div");
   if(i>=0) {
   	var b = document.createElement("b");
   	b.appendChild(document.createTextNode(str));
   	td.appendChild(document.createTextNode(val.substring(0,i)));
   	td.appendChild(b);
   	td.appendChild(document.createTextNode(val.substring(i+str.length)));
   } else {
   	td.appendChild(document.createTextNode(val));
   }
   
   //var td = document.createElement("div");
   //td.appendChild(document.createTextNode(tr[0]));
   td.setAttribute("resultName", tr[0]);
   td.setAttribute("resultValue", tr[1]);
   td.className = "dojoComboBoxItem " + ((even) ? "dojoComboBoxItemEven" : "dojoComboBoxItemOdd");
   even = (!even);
   this.optionsListNode.appendChild(td);
}

Try some alternatives: