jquery - Replace Flash Notice with Bootstrap Modal in Rails -


so have page user clicks button , posts form , uploads pdf file in background. upon completion of posting form, flash notice appears saying pdf has been uploaded. i'd show modal instead of flash notice when background pdf upload complete. how can that?

pages_controller.rb

def send_pdf   require "net/http"   uri = uri('http://www.skillchest.com/users/receive_certificate')   x = net::http.post_form(uri, params)   puts x.body   redirect_to pages_course_page_certificate_path, notice: 'you have sent pdf <u><a href=http://www.website>website</a></u>. login check out!'.html_safe   ## how make above line show modal instead of flash notice? end 

course_page_certificate.html.erb

<h1>congratulations! here certificate.</h1> <%= form_tag({controller: "pages", action: "send_pdf"}, method: "post") %> <%= hidden_field_tag(:end_date, @today) %> <% url = current_user.certificate.s3_object.url_for(:read, :expires => 10*60) %> <%= hidden_field_tag(:pdf_url, url) %> <%= hidden_field_tag(:student_email, current_user.email) %> <%= hidden_field_tag(:institution_id, '2') %> <%= hidden_field_tag(:course_title, 'lesson 1') %> <%= submit_tag "send certificate skillchest", class: "btn btn-warning btn-lg continue" %> 

when user clicks "send certificate" button, certificate posted url in controller action. notice appears says succesffully sent. works fine, show modal on completion of http post action rather flash notice. how this?

thanks!

screenshot

so isn't perfect answer, notice still there, here's did modal working.

i checked if alert class html contained notice message. if does, show modal want. of course ideally show modal , not notice, still haven't figured part out yet.

if ($(".alert").html().indexof("you have sent your") >= 0) {   $("#sendtoskillchestmodal").modal(); } 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -