Meteor.js - 会话无法在移动浏览器中运行

时间:2013-07-13 19:36:53

标签: session mobile meteor

Meteor Session set and get在所有桌面浏览器中都能正常工作,但触发Sessions的相同事件在移动Safari浏览器中被“破坏”。在使用Meteor Session变量的同时还有解决方法吗?

以下是一些代码的示例。

Template.stream.events({
  'click #circusview': function () {
    var thisValue = document.getElementById("circusview");
    var thisVal = thisValue.getAttribute("title");
    Session.set("selected", thisVal);
    var theSesh = Session.get("selected");
  }
}) 

Template.tweet.tmplView = function () {
  var thisSesh = Session.get('selected');
  return thisSesh;
} 

<template name="tweet">
  <div id="{{tmplView}}" class="tweet" style="background-image: url( '{{backImg}}' )" >
    <img class="profile" src="{{profileImg}}">
    <span class="name">{{screenName}}</span>
    <span class="message"> {{thisMessage}}</span>
  </div>
</template>

此代码的工作方式类似于桌面浏览器上的魅力,但不适用于移动版Safari。谢谢你的帮助。

2 个答案:

答案 0 :(得分:0)

移动版Safari究竟发生了什么?是否触发了click功能?会话是否正确设置?你能测试一下吗?

尝试此更改:

Template.stream.events({
  'mouseup #circusview, touchend #circusview': function(e) {
    Session.set('selected', $(e.target).attr('title'));
  },
});

答案 1 :(得分:0)

谢谢休伯特 -

以下是最终在桌面和移动设备上运行的代码。

Template.stream.events({
  'mouseup #circusview, touchend #circusview': function(e) {
   var thisValue = document.getElementById("circusview");
   var thisVal = thisValue.getAttribute("title");
   Session.set("selected", thisVal);
  }
})
相关问题