I've had a thought about this which may make it slightly more efficient.

Instead of generating each selectbox on load, along with their respective
options, wouldn't it be better to create on hover, and then hide it when the
element is mouseout'd.


If the element is then hovered over again, then check to see if it exists,
and show if it is. I see something like this:



$("#tablename td", this).hover(
  function(element){
    if (/* If select exists in element (not sure if
$("select",element).find() would return bool or not)... */)
    {
      $("select",element).show();
    }
    else
    {
       /* Usual select creation code here */
    }
  },function(element){
    /* Turn selected value/text into element text */
    $("select",element).hide();
  }
)



I'm bringing this up here because, when I first tried out Sam's code, I
experienced massive delays in loading, as several hundred td's were
populated with select boxes (even when there were just two options). When
creating them on the fly, I saved a lot of time, as it only had to create
them, and hide them when they moved the mouse away.


Anyhoo, tell me if I'm crazy and don't know enough about JS (I don't! ;)).
This just seems a better way to do things on large datasets where the
loading time needs to be less than 20+ seconds.
-- 
View this message in context: 
http://www.nabble.com/Dynamically-adding-select-boxes-tf1884044.html#a5726902
Sent from the JQuery forum at Nabble.com.


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to