Is this you are looking for?
if(!window.WebGLRenderingContext) {
$("#div_id").html(<%= rails_helper %>);
}
else {
$("#div_id").html(<%= use_another_rails_helper %>);
}
Frage
I want to decide which content to render in a Rails app depending on WebGL support.
I know I can check for WebGL from JS
if (!window.WebGLRenderingContext) {
return; }
But how can I use that to decide what to render in html.erb?
I want something like
if (!window.WebGLRenderingContext) {
// Use some <%= rails_helper %>
}else{
// <%= use_another_rails_helper %>
}
Lösung
Is this you are looking for?
if(!window.WebGLRenderingContext) {
$("#div_id").html(<%= rails_helper %>);
}
else {
$("#div_id").html(<%= use_another_rails_helper %>);
}