zoukankan      html  css  js  c++  java
  • 前端小结(一)

            detail: function(theTag){
                var log_id = $(theTag).attr('data-id');
                var log_content = current_list[log_id];
                log_content['response'] = JSON.parse(log_content['response']);
                var url = "/admin/log/error_log/ajax_error_log_detail";
                var $theModal = $('#ajax_error_log_modal');
                comm.ajaxModal(function(){
                    var show_tag = $theModal.find('.modal-body .log-show');
                    $(show_tag).text(JSON.stringify(log_content, null, 2));
                }, $theModal, url, { '90%'});

    需求:mongodb一次性返回全部数据,需要将单条数据的详情,显示在详情页上。

    自己问他:能将数据准备好,但是没办法将数据绑定到详情页。

    解决:俊哥当面敲代码解决。

    分析:1.在思路上,没有将准备好的数据,想到用_id标识出来,总是想一次性全部传到detail中

    2.没有想到利用全局变量。俊哥是通过将单条数据通过_id 标识出来,然后添加到全局变量中,再通过每条数据中的_id直接传到detail函数中;然后在detail中,通过_id从全局变量中获取所需要的详情信息。

    3.在讲详情信息绑定到详情modal中,对jquery不熟悉的缺点暴露无遗。

    $(theTag).attr('data_id'):$(theTag)没有想到

    var show_tag = $theModal.find('.modal-body .log-show'): 只知道照搬原来的,不知道如何根据需要去做修改
    $(show_tag).text(JSON.stringify(log_content, null, 2));将数据json 结构化输出到html中不熟悉,text()函数将值绑定到对应的div标签中也不熟悉

    所以总的来说,不熟悉的用法有:
    $().attr() 获取标签中元素的属性值
    find() jQuery find()函数
    $().text() jquery text()函数,将值显示到页面上


  • 相关阅读:
    Codeforces Round #522(Div. 2) C.Playing Piano
    zstu月赛 招生
    Codeforces Round #519 D
    RMQ[区间最值查询] 算法
    Codeforces #364 (Div. 2) D. As Fa(数学公式推导 或者二分)
    尺取法
    Codeforces #366 (Div. 2) D. Ant Man (贪心)
    Codeforces #366 Div. 2 C. Thor (模拟
    裴蜀定理
    CF850 E. Random Elections
  • 原文地址:https://www.cnblogs.com/wangzhao2016/p/7146209.html
Copyright © 2011-2022 走看看