如何绑定来自2个JQuery函数的数据?

时间:2016-07-19 21:38:51

标签: javascript jquery twitter-bootstrap

在我的示例中,我尝试将$('#integrate_employee_popup').modal('show');$("#integrate_employee_popup").bind('show',function(e) {});绑定。它曾经是一个块UI,现在是升级时间来引导JQuery以提高响应速度。

旧命令是$('#integrate_employee_popup').trigger('block')$("#integrate_employee_popup").bind('block',function(e) {});。我必须在这里错过一些元素来插入它。

$(".integrate_employee_link").click(function(e) {
  button_id = this.id;
  employee_question_id = this.id.split('_')[2];
  integrate_employee_target = ($(this).attr('target')===undefined)?'':$(this).attr('target');
  integrate_employee_onunblock = ($(this).attr('onunblock')===undefined)?'':$(this).attr('onunblock');
  integrate_employee_jsonID = ($(this).attr('jsonID')===undefined)?'jsonID':$(this).attr('jsonID');
  integrate_employee_columns = ($(this).attr('columns')===undefined)?'fname=First Name, lname=Last Name':$(this).attr('columns');
  integrate_employee_select = ($(this).attr('tooltype')===undefined)?'radio':$(this).attr('tooltype');
  integrate_employee_employeetype = ($(this).attr('employeetype')===undefined)?'basic':$(this).attr('employeetype');
  integrate_employee_searchresultlabel = ($(this).attr('searchresultlabel')===undefined)?'Existing Active Employees':$(this).attr('searchresultlabel');
  integrate_employee_selectmod = ($(this).attr('selectmod')===undefined)?'':$(this).attr('selectmod');
  integrate_employee_frommod = ($(this).attr('frommod')===undefined)?'':$(this).attr('frommod');
  integrate_employee_wheremod = ($(this).attr('wheremod')===undefined)?'':$(this).attr('wheremod');
  integrate_employee_secondquery = ($(this).attr('secondquery')===undefined)?'':$(this).attr('secondquery');
  integrate_employee_tool =($(this).attr('tool')===undefined)?'':$(this).attr('tool');
  integrate_jobtitleID = $('#integrate_employee_form #employee_form_jobtitleID').val();
  integrate_categoryID = $('#integrate_employee_form #employee_form_categoryID').val();
  integrate_shiftID = $('#integrate_employee_form #shiftID').val();
  $('#integrate_employee_popup').modal('show');
  return false;
});

$("#integrate_employee_popup").bind('show',function(e) {
  $('#target').val(integrate_employee_target);
  $('#jsonID').val(integrate_employee_jsonID);
  $('#employeesearchlabel').html(integrate_employee_searchresultlabel);
  $('#integrate_employee_desc').val('');
  integrate_employee_searchresults();
});

1 个答案:

答案 0 :(得分:0)

对于Bootstrap文档,您应该使用show.bs.modal事件,check this list

因此,假设身份integrate_employee_popup的元素已经是Bootstrap模式,您可以这样做:

$("#integrate_employee_popup").bind('show.bs.modal',function(e) {
   //your code goes here
}

此外,如果我的想法没有让我失望,return false中的jQuery click可能会停止事件传播。