JS循环中使用bind函数的参数传递问题,问题代码如下:
for (var sc in result) {
var tempp = '<div class="sidebar_todo_temp">' +
'<img src="grpcd/common/img/close_s.png">' +
'<p class="senderman">' +
result[sc].senderuser +
'</p>' +
'<p class="vtitle">' +
result[sc].title +
'</p>' +
'<p class="senddate">' +
fommatDate(result[sc].sendtime) +
'</p>' +
'</div>';
var pp = $(tempp);
pp.hover(
function() {
$(this).find('p').css('background-color', '#2C2424');
},
function() {
$(this).find('p').css('background-color', '#666666');
}
); $("#sidebar_todo_area").append(pp);
pp.bind('click', function() {
var opt = {
num: 400,
title: "页签",
imgsrc: "",
url: "workflow/towfdeal.do?recordid=" + result[sc].recordid + "&nid=" + result[sc].nid + "&checkflowid=" + result[sc].id + "&inforid=" + result[sc].inforid+"&taskid=" + result[sc].taskid,
width: 300,
height: 300,
circleurl: "",
preloading: 0
};
Core.createPageNC(opt);
});
}

传入的参数是循环的最后一次构造的,改造代码如下:

  for (var sc in result) {
var tempp = '<div class="sidebar_todo_temp">' +
'<img src="grpcd/common/img/close_s.png">' +
'<p class="senderman">' +
result[sc].senderuser +
'</p>' +
'<p class="vtitle">' +
result[sc].title +
'</p>' +
'<p class="senddate">' +
fommatDate(result[sc].sendtime) +
'</p>' +
'</div>';
var pp = $(tempp);
pp.hover(
function() {
$(this).find('p').css('background-color', '#2C2424');
},
function() {
$(this).find('p').css('background-color', '#666666');
}
);
var urll="workflow/towfdeal.do?recordid=" + result[sc].recordid + "&nid=" + result[sc].nid + "&checkflowid=" + result[sc].id + "&inforid=" + result[sc].inforid+"&taskid=" + result[sc].taskid;
var numm=result[sc].taskid;
alert(numm);
var opt = {
num: numm,
title: "页签",
imgsrc: "",
url: urll,
width: 300,
height: 300,
circleurl: "",
preloading: 0
};
$("#sidebar_todo_area").append(pp);
pp.bind('click', opt,function(e) {
Core.createPageNC(e.data);
});
}

JS循环中使用bind函数的参数传递问题的更多相关文章

  1. JQuery实战中遇到的两个小问题$(document).ready() 、bind函数的参数传递问题

    一.$(document).ready() 与 window.onload的区别 1.执行时间 window.onload 必须等到页面内所有元素(包括图片 css js等)加载完毕后才会执行. $( ...

  2. Handlebars.js循环中索引(@index)使用技巧(访问父级索引)

    使用Handlebars.js过程中,难免会使用循环,比如构造数据表格.而使用循环,又经常会用到索引,也就是获取当前循环到第几次了,一般会以这个为序号显示在页面上. Handlebars.js中获取循 ...

  3. js的for循环中出现异步函数,回调引用的循环值总是最后一步的值?

    这几天跟着视频学习node.js,碰到很多的异步函数的问题,现在将for循环中出现的异步函数回调值的问题总结如下: 具体问题是关于遍历文件夹中的子文件夹的,for循环包裹异步函数的代码: for (v ...

  4. js 中的bind函数

    bind是Function.prototype中内置函数 作用是指定函数作用域 代码参考 http://blog.csdn.net/load_life/article/details/7200381 ...

  5. 原生JS实现call,apply,bind函数

    1. 前言 使用原生JS实现call和apply函数,充分了解其内部原理.call和apply都是为了解决改变this的指向.作用都相同,只是传参的方式不同.除了第一个参数外,call可以接受一个参数 ...

  6. Javascript中的bind()函数

    今天看到公司大神的一段代码: function ReplaceProcessor() { this._dom = { btnReplace: $('#ro_btnReplace'), btnCompl ...

  7. python易错题之lambda 以及 for循环中内嵌函数

    li = [] for x in range(10): print(x) //在函数没有执行前(li[0]()),for 循环中x已经执行完,x会一直为 9 def fun(): print(x) / ...

  8. js循环中使用async/await踩过的坑

    最近写koa的时候遇见需要在循环中使用async/await的情况,当然第一反应就是直接上forEach,然后就直接翻车了... 直接上代码: function handleSql(val) { re ...

  9. JS实现call,apply,bind函数

    实现之前的预备知识 ...用作展开 ...用作剩余参数 Object.create()的作用 原型链与构造函数 这些有时间补上吧 call函数实现 Function.prototype.myCall ...

随机推荐

  1. linux awk 内置函数实例

    awk内置函数,主要分4种:算数函数.字符串函数.时间函数.一般函数 一.算术函数 以下算术函数执行与 C 语言中名称相同的子例程相同的操作: 函数名 说明 atan2( y, x ) 返回 y/x ...

  2. linux文件句柄数

    1.问题阐述: too many open files:顾名思义即打开过多文件数. 不过这里的files不单是文件的意思,也包括打开的通讯链接(比如socket),正在监听的端口等等,所以有时候也可以 ...

  3. socket、tcp、udp、http 的认识及区别

    一.先来一个讲TCP.UDP和HTTP关系的 1.TCP/IP是个协议组,可分为三个层次:网络层.传输层和应用层. 在网络层有IP协议.ICMP协议.ARP协议.RARP协议和BOOTP协议. 在传输 ...

  4. 初识 tk.mybatis.mapper 通用mapper

    在博客园发表Mybatis Dynamic Query后,一位园友问我知不知道通用mapper,仔细去找了一下,还真的有啊,比较好的就是abel533写的tk.mybatis.mapper. 本次例子 ...

  5. linux RPM manager

    RPM manage:rpm2cpio package_name | cpio -id #将一个rpm包解压至当前目录rpm -qi package_name #查看一个已安装的rpm包信息rpm - ...

  6. Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-C-Bracket Subsequence

    #include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> ...

  7. Record for Individual Project ( Word frequency program )

    1.  预计时间 ● 对问题总体的理解.规划:10 min ● 设计编写程序:5 h ● 调试: 分模块-40 min; 总体-40min ● 测试(性能分析).改进:1 h 2.  实际用时 ● 对 ...

  8. Oracle 转移符问题

    注:select '''' from dual;    --输出一个单引号      select '''''' from dual;   --输出两个单引号      select '''''''' ...

  9. C# 中颜色和名称样式对照表

    WPF中的画刷也一样适用 System.Windows.Media.Brushes.名称 (如:System.Windows.Media.Brushes.AliceBlue) :first-child ...

  10. CI框架2.x的验证码中所遇问题解决

    用php版本是5.6,CI框架版本是2.x,在使用验证码(captcha)时,遇到一些问题. 首先,我查看框架手册,说必需的两个参数是"img_url",“img_path”,其他 ...