简体   繁体   中英

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM