【问题标题】:Using JS-variable in Yesod handler's code在 Yesod 处理程序的代码中使用 JS 变量
【发布时间】:2015-07-09 07:15:46
【问题描述】:

我知道我们可以在 Julius-code 中使用 Haskell 数据,例如:

$(function(){
    $("section.#{sectionClass}").hide();
});

但是如何在 Haskell 代码中使用 JS 变量呢?例如:

... in some .julius
$(function set_global_variable( value ) {
    window.myGlobalValue = value;
});

... in some handler, pseudocode:
getMyPageR :: Handler Html
getMyPageR = do
    let globalValue = [julius|window.myGlobalValue;|]
    ...

有可能吗?

【问题讨论】:

    标签: javascript yesod yesod-julius


    【解决方案1】:

    不,没有办法做到这一点。 yesod 代码运行服务器端和 JavaScript 客户端。如果事情是让 JavaScript 将值发送回服务器,那么实现这种情况的唯一方法。

    【讨论】:

      猜你喜欢
      • 2013-12-09
      • 1970-01-01
      • 1970-01-01
      • 2017-09-17
      • 2020-01-12
      • 2017-02-27
      • 1970-01-01
      • 2015-03-16
      • 1970-01-01
      相关资源
      最近更新 更多