jquery .live(), event binding and ajax
I have a few buttons and select box. When i click on a button its sending ajax request and returning {"ids":{"attr_id":"1","subattr_id":"6"}}
attr_id
here is value that i set to selectbox. According to attr_id
generated second select box, which value need to set to subattr_id
.
.onClick()
button event :
$.post(
function(result){
jQuery(result.ids).each(function(){
var prodAttr = $(this).attr('attr_id');
开发者_如何转开发 $('div.attribute_wrapper select.property').change(function(e,eType){
if(eType == 'click')
{
prodSubattr = $(result.ids).attr('subattr_id');
$(this).trigger('cascadeSelect',prodAttr);
//select.subProperty generated by ajax when first selectbox changed
$('select.subProperty').trigger('setValue',prodSubattr);
}
});
$('div.attribute_wrapper select.property').trigger('change',e.type);
$('select.subProperty').live('setValue', function(e, subAttr){
$(this).val(subAttr);
});
});
}
)
Value of second selectbox didnt changing. So i need some help with this issue.
setValue isn't an event. Consider creating a function and calling that instead.
http://api.jquery.com/live/
精彩评论