0

Is it possible to create a QR code that redirects the user to a modal in a specific page? As in, you send him to the page X but already trigger click <%= link_to "modaltoshow %> , and the user sees the modal immediately after scanning.

Thanks

zukuyama
  • 55
  • 2

1 Answers1

0

If your question is simply "can I launch a page with a modal already open," the answer is yes. You'd just need a javascript that launches it on load, like the selected answer here.

Assuming you need some ruby logic, you could simply change the target of that script with embedded ruby based upon a parameter the QR code passes (for instance, if you have a parameter "target_modal" that is the target modal's id, just reference that in the script). It could look something like this in your script block:

<!-- The if statement just checks for the parameter. If the parameter will
     always be present, you may remove this. -->
<% if params(:target_modal) %>
    $(window).load(function(){
        $('<%= params(:target_modal) %>').modal('show');
    });
<% end %>
Community
  • 1
  • 1
ConnorCMcKee
  • 1,625
  • 1
  • 11
  • 23
  • Thanks. Gotta try that last example. I have a page with persons and once ya click ya get a modal( with the same id as the person clicked) with personal info of each one. The idea is having QR codes for each person that redirect the user straight to the correct person modal. – zukuyama May 25 '16 at 18:59
  • 1
    Got it working thanks <% if params[:target_modal_person_id] %>
    <% end %>
    – zukuyama May 26 '16 at 19:30