Pregunta

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 %>
 }
¿Fue útil?

Solución

Is this you are looking for?

 if(!window.WebGLRenderingContext) {
   $("#div_id").html(<%= rails_helper %>);
  }
else {
   $("#div_id").html(<%= use_another_rails_helper %>);
 }
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top