I've tried to understand "bubbling" and I think my problem has something to
do with that, but I'm not sure. Basically, it seems to me that an event
fires on a SELECT element even when the page simply loads.

I need to know how to either:

a.) prevent this initial firing, so that my .change function is only
processed when the user actually does something (whether with the keyboard
or the mouse),
or
b.) figure out how to distinguish between the two kinds of event firing
(window just loading versus user actually doing something).

Right now, the #textInputExample INPUT element gets overwritten by the
returned contents from something.php the second the page loads (before the
user has had a chance to even view the original contents of the box).

$(function(){
  $("select#foo").change(function() {
    var str = $("#foo option:selected").val();
    $.post("something.php", 
      {filepath: str}, 
      function(xml) {
        $("#textInputExample").val($("blort", xml).text());
    });
  }).change();
});

<select id="foo">
  <option value="lalala">lalala</option>
  <option value="hmmmm">hmmmm</option>
</select>

<input type="text" id="textInputExample" value="" />

-- 
View this message in context: 
http://www.nabble.com/Event-handling%2C-bubbling%2C-and-SELECT-change-tp20777794s27240p20777794.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to