Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何通过双击“编辑行中的元素”;在《流星》中;_Javascript_Meteor_Bootstrap Modal - Fatal编程技术网

Javascript 如何通过双击“编辑行中的元素”;在《流星》中;

Javascript 如何通过双击“编辑行中的元素”;在《流星》中;,javascript,meteor,bootstrap-modal,Javascript,Meteor,Bootstrap Modal,我想通过双击行中的元素来打开引导模式,以便能够对其进行编辑 比如说,当我双击名称(Nuriddinhon)时,模态视图应该会打开该Nuriddinhon,我应该能够编辑该名称。 这是我的js文件: Template.projectRow.events({ 'dblclick .projectRow':function(evt,tmpl) { Session.set('editing_project', tmpl.data._id); //what should

我想通过双击行中的元素来打开引导模式,以便能够对其进行编辑

比如说,当我双击名称(Nuriddinhon)时,模态视图应该会打开该Nuriddinhon,我应该能够编辑该名称。

这是我的js文件:

Template.projectRow.events({
    'dblclick .projectRow':function(evt,tmpl) {
        Session.set('editing_project', tmpl.data._id);
    //what should be here?
    }
});
和html文件:

<template name="projects">

{{>projectForm}}

<div class="container">
    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header">Project
                <small>List</small>
            </h1>
            <button class="btn btn-lg btn-success addProject" data-toggle="modal" data-target="#myModal" type="button">Add project</button>
        </div>
        <table class="table table-bordered table-hover table-stiped">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Client</th>
                    <th>Due Date</th>
                    <th>Status</th>
                </tr>
            </thead>
            <tbody>
            {{#each projectList}}
            {{>projectRow}}
            {{/each}}
            </tbody>
        </table>
    </div>
</div>

{{>projectForm}
项目
列表
添加项目
名称
客户
到期日
地位
{{{#每个项目列表}
{{>projectRow}
{{/每个}}


{{name}}
{{client}}
{{formatDate duedate}}
{{status}}


&时代;
添加项目
姓名:
客户:
地位:
暂停
活跃的
保存更改
取消

我想我可以解释我的愿望,为我的语言错误感到抱歉:-(

而不是
data toggle=“modal”
将其更改为:

data-toggle="dbl-modal"
在jQuery中,如果您有
文档
s
ready
函数,请添加以下内容:

$(document).on('dblclick', '[data-toggle="dbl-modal"]', function (e) {
  e.preventDefault();
  $($(this).attr("href")).modal("show");
});
让我知道它是否有效。您可以将其添加到
bootstrap.min.js
或自定义JavaScript文件中

工作小提琴

$(document).on('dblclick','[data toggle=“dbl modal”]',函数(e){
e、 预防默认值();
$($(this.attr(“href”).modal(“show”);
});
body{padding:25px;}

&时代;
情态标题
一个好身体&hellip

接近 保存更改
您可以使用简单的方法实现此目的

假设您有这样一个模板

<template name="myModalToEdit">
 {{! Modal Content }}
</template>
Template.projectRow.events({
    'dblclick .projectRow':function(evt,tmpl) {
      dataToModal = {
       id: tmpl.data._id
     };
      Blaze.renderWithData(Template.myModalToEdit, dataToModal, document.body)
    }
});
现在,您需要在
myModalToEdit
模板的
.js
中添加以下代码

<template name="myModalToEdit">
 {{! Modal Content }}
</template>
Template.projectRow.events({
    'dblclick .projectRow':function(evt,tmpl) {
      dataToModal = {
       id: tmpl.data._id
     };
      Blaze.renderWithData(Template.myModalToEdit, dataToModal, document.body)
    }
});
Templae.myModalToEdit.onRendered(function(){ 
  var tmpl = this;

  $('#modal-selector').modal(); //Launch the modal

  console.log(tmpl.data); // should the print the data passed on dataToModal Variable
});