Side navigation
#9831 closed bug (invalid)
Opened July 15, 2011 09:58AM UTC
Closed July 15, 2011 01:13PM UTC
children() bug
| Reported by: | anonymous | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | None |
| Component: | unfiled | Version: | 1.6.2 |
| Keywords: | Cc: | ||
| Blocked by: | Blocking: |
Description
to reproduce
run the following code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>document</title>
<style type="text/css">
select{
width: 140px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script>
(function($){
$.fn.multiSelect = function(){
var $this = $(this);
var selects = $this.children();
selects.live('click change',function(){
alert('de');
});
};
})(jQuery);
(function($){
$.fn.multiSelect2 = function(){
var $this = $(this);
var selects = $this.find('select');
selects.live('click change',function(){
alert('de');
});
};
})(jQuery);
$(function(){
$('#catform').multiSelect();
});
</script>
</head>
<body>
<form id="catform" class="c">
<select size="10" class="cat1" name="cat1">
<option value="property" >bất động sản</option>
<option value="service" >dịch vụ</option>
</select>
<select size="10" class="cat2" name="cat2" style="margin:0 15px">
<option value="job-21" >an ninh - bảo vệ</option>
<option value="pet-4" >khác</option>
</select>
<select size="10" class="cat3" name="cat3">
<option value="clothing-1-11" >ví</option>
<option value="computer-11-3" >webcam</option>
</select>
</form>
</body>
</html>
Then try to run multiSelect2 on $('.catform'). you will see, the code is basically the same, but multiSelect 2 will work, multiSelect() will not
Attachments (0)
Change History (1)
Changed July 15, 2011 01:13PM UTC by comment:1
| resolution: | → invalid |
|---|---|
| status: | new → closed |
Thank you for your time and interest in helping the jQuery project, but I am reasonably confident that this is not a bug. As it is stated on the docs for .live,
.children() is a traversal method - as is find - so to be honest, I'm surprised it's working in either case, but the former *certainly* is not supported. This seems like an ideal use case for .delegate over .live