如何在coffeescript中显示变量值

时间:2014-10-14 11:01:56

标签: coffeescript

jQuery ->
  test = path
  if $('#spot-index-sortable').length > 0

    $('#spot-index-sortable').sortable(

      axis: 'y'
      items: '.item'
      cursor: 'move'

      sort: (e, ui) ->
        ui.item.addClass('active-item-shadow')
      stop: (e, ui) ->
        ui.item.removeClass('active-item-shadow')
        # highlight the row on drop to indicate an update
        ui.item.children('td').effect('highlight', {}, 1000)
      update: (e, ui) ->
        item_id = ui.item.data('item-id')
        console.log(item_id)
        position = ui.item.index() # this will not work with paginated items, as the index is zero on every page
        $.ajax(
          type: 'POST',
          url: test+'admin/spot_categories/update_row_order',
          dataType: 'json',
          data: { category: {category_id: item_id, row_order_position: position } }
        )
    )

变量测试将具有来自javascript的值,然后我想在$ .ajax(url:test)上连接上面的测试变量值。怎么做

1 个答案:

答案 0 :(得分:0)

试试这个:注意双引号

url: "#{test}/admin/spot_categories/update_row_order",