0

我想在Meteor的Bootstrap列表项上实施向左滑动的&滑动事件。 Meteor使用Cordova为移动应用程序开发提供WebView。我想知道是否有可能在Blaze这个Meteor的前端库中处理像滑动,触摸等等jQuery Mobile事件? 以下是Meteor official TO-DO tutorial sample的一个基本示例。是否有可能处理流星中的jQuery Mobile事件?

参见tasks.html文件是:

<template name="task"> 
    <li class="{{#if checked}} checked {{/if}}"> <!-- set the CSS for a checked task --> 
     <input type="checkbox" checked="{{checked}}"> 
     {{#if isOwner}} 
      <button class="toggle-private"> 
       {{#if private}} 
        Private 
       {{else}} 
        Public 
       {{/if}} 
      </button> 
     {{/if}} 

     <span class="text">{{text}}</span> 
     <span class="createdBy"> 
      {{#if createdBy}} 
       by {{createdBy}} 
      {{else}} 
       by anonymous user 
      {{/if}} 
     </span> 
     <a class="js-delete-task" id="deletetask" href="#" > 
      <i class="fa fa-trash-o pull-right" aria-hidden="true"></i> 
     </a> 
    </li> 
</template> 

这是它的火焰/ JavaScript的对手,tasks.js;

Template.task.helpers({ 
    isOwner: function() { 
     console.log(`this.createdBy is ${this.createdBy}`); 
     return (this.createdBy === Meteor.user().username); 
    }, 
    private: function() { 
     return this.private; 
    } 
}); 

Template.task.events({ 
    'click .js-check-task': function(event, template){ 
     if(this._id) { 
      console.log("Check the task, converting to: ", !this.checked); 
      Meteor.call('tasks.check', this._id, this.checked); 
     } 
    }, 
    'click .js-delete-task': function(event, template){ 
     console.log("Deleting the task: ", this._id); 
     if(this._id) { 
      console.log(`Calling deleteTask()`); 
      Meteor.call('tasks.delete', this._id); 
     } 
    }, 

    'click .toggle-private': function(event, template) { 
     console.log(`Toggling private`); 
     if(this._id) { 
      console.log(`Calling task.togglePrivate`); 
      if (this.private === null || this.private === undefined) 
       Meteor.call('tasks.setPrivate', this._id, false); 
      else 
       Meteor.call('tasks.setPrivate', this._id, this.private); 
     } 
    } 
}); 

我正在寻找一种方法来实现列表项上的移动滑动左/右事件。如果用户滑动左侧列表项(任务),我想显示转发或删除图标等。

+0

我已经使用滑动。效果很好。但是,如果你可以更具体,并分享一些代码(如果不工作),它会很好。 – Ankit

+0

@Ankit,我提供了上面的代码,实际上来自基本的Meteor教程。 –

+0

我最近使用这个包实现了滑动事件:https://github.com/gwendall/meteor-swing – Ankit

回答

相关问题