coffeescript - Parsing AJAX response in callback -


i need access piece of data html response in ajax callback.

in coffeescript, want access completion-id data attribute. when following:

  $('.mark-completed')     .bind "ajax:success", (event, data) ->         console.log data         console.log $(data) 

i in console data:

<li class="learning_item_completion" data-completion-id="162" data-user-id="2" id="learning_item_completion_162">   <div class="item-icon">     <img alt="thumb_alex_headshot_green_200x200" class="circular" height="60" src="/uploads/user/picture/2/thumb_alex_headshot_green_200x200.png" width="60" />   </div>   <div class="item"> 

and $(data):

[li#learning_item_completion_162.learning_item_completion, jquery: "1.9.1", constructor: function, init: function, selector: "", size: function…]   0: li#learning_item_completion_162.learning_item_completion   accesskey: ""   attributes: namednodemap   0: class   1: data-completion-id     ...     nodevalue: "162"     value: "162"     ... 

what's right way access completion-id?

simply add :

$('.mark-completed') .bind "ajax:success", (event, data) ->     cid = $(data).find('.learning_item_completion').data('completion-id')     console.log cid 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -