0

我在这里接近边缘,所以任何帮助将不胜感激。我试图使每一行数据成为可点击的链接,并且该链接将是 JSON 数据中的 id。这背后的想法是,一旦用户点击一个链接,代码就会在我的应用程序的另一个页面上填充一个表单。

在使用 Actionscript 多年后,我刚刚开始学习 Jquery,但目前进展并不顺利。

JSON数据

var data = [
{ 
    "code" : "SF700JR",
    "color" : "Orange",
    "description" : "RAL 2000",
    "finish" : "Smooth",
    "gloss" : "Satin",
    "id" : "uk1",
    "series" : "D1036"
  },
    {
    "code" : "YA602GF",
    "color" : "White",
    "description" : "RAL 9016",
    "finish" : "Smooth",
    "gloss" : "Gloss",
    "id" : "uk2",
    "series" : "D2525 SD"
  },
  { "code" : "YA604GF",
    "color" : "White",
    "description" : "RAL 9018",
    "finish" : "Smooth",
    "gloss" : "Gloss",
    "id" : "uk3",
    "series" : "D2525 SD"
  }
]

查询

  var dynatable = $('#my-final-table').dynatable({
    features: {
      paginate: false,
      recordCount: false,
      sorting: false,
      search: false
    },
    dataset: {
      records: data
    }
  }).data('dynatable');

  $(data).each(function(index, value) {
    var row_content = $('<a href="#">' + value.id + '</a>');
    value.id = row_content;
    console.log(row_content);
    $('#my-final-table tr').append('<a href="#">'+value.color+'</a>').data(value);

    $('#my-final-table tr a').on('click', function(){
      console.log("click");
    });
  });

HTML

<div class="ui-grid-solo"><p></p>
    <div class="ui-block-a">
    <table id="my-final-table" class="product-table" style="width:100%">
        <thead>
            <th class="table-heads">Description</th>
            <th class="table-heads">Code</th>
            <th class="table-heads">Series</th>
            <th class="table-heads">Color</th>
            <th class="table-heads">Gloss</th>
            <th class="table-heads">Finish</th>
            <th class="table-heads">ID</th>
        </thead>
        <tbody>
        </tbody>
    </table>
    </div>
</div>
4

0 回答 0