[英]How to render html.erb conditionally from javascript (WebGL check)
我想根据WebGL支持来决定在Rails应用程序中呈现哪些内容。
我知道我可以从JS检查WebGL
if (!window.WebGLRenderingContext) {
return; }
但是,如何使用它来决定在html.erb中呈现什么呢?
我想要类似的东西
if (!window.WebGLRenderingContext) {
// Use some <%= rails_helper %>
}else{
// <%= use_another_rails_helper %>
}
这是您要找的吗?
if(!window.WebGLRenderingContext) {
$("#div_id").html(<%= rails_helper %>);
}
else {
$("#div_id").html(<%= use_another_rails_helper %>);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.