Javascript 在Yesod处理程序中使用JS变量';s代码
我知道我们可以在Julius代码中使用Haskell数据,例如:Javascript 在Yesod处理程序中使用JS变量';s代码,javascript,yesod,yesod-julius,Javascript,Yesod,Yesod Julius,我知道我们可以在Julius代码中使用Haskell数据,例如: $(function(){ $("section.#{sectionClass}").hide(); }); ... in some .julius $(function set_global_variable( value ) { window.myGlobalValue = value; }); ... in some handler, pseudocode: getMyPageR :: Handler H
$(function(){
$("section.#{sectionClass}").hide();
});
... 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;|]
...
但是如何在Haskell代码中使用JS变量呢?例如:
$(function(){
$("section.#{sectionClass}").hide();
});
... 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;|]
...
有可能吗?没有,没有办法。yesod代码在服务器端和JavaScript客户端运行。实现这一点的唯一方法是让JavaScript将值发送回服务器