【问题标题】:Meteor.js - Session not working in mobile browsersMeteor.js - 会话在移动浏览器中不起作用
【发布时间】:2013-07-15 04:26:53
【问题描述】:

Meteor Session 设置和获取在所有桌面浏览器上对我来说都运行良好,但触发 Session 的相同事件在移动 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 上却不行。感谢您的帮助。

【问题讨论】:

    标签: session mobile meteor


    【解决方案1】:

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

    试试这个改变:

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

    【讨论】:

    • 谢谢。这是正在运行的代码。 Template.stream.events({ 'mouseup #circusview, touchend #circusview': function(e) { var thisValue = document.getElementById("circusview"); var thisVal = thisValue.getAttribute("title"); Session.set( "选中", thisVal); },
    【解决方案2】:

    感谢休伯特 -

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

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

    【讨论】:

      猜你喜欢
      • 2015-05-02
      • 1970-01-01
      • 2012-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-24
      • 2017-09-19
      相关资源
      最近更新 更多