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

回答

相關問題