Yesha
Yesha

Reputation: 678

Add notification at the bottom of every page in rails

I have a rails application in which I show a notification at the bottom of my home page using overhang.js I want to extend this functionality of showing this notification on all pages. I am assuming this can be done using aplication.html.erb file but I don't understand how? The body tag of my application.html.erb file is given below:

<body>
  <div>
    <%= render 'layouts/header' %>
    <div>
        <%=yield%>
    </div>
    <%= render 'layouts/footer' %>
  </div>
</body> 

The script for overhang.js that exists currently on home page is given below:

$("body").overhang({
      type: "confirm",
      primary: "#8dc153",
      accent: "#FCE4EC",
      yesColor: "#3498DB",
      message: "Privacy policy",
      overlay: true,

      callback: function (value) {
        var response = "Okay";
        #code to handle response
      }
    });

I want to add this notification at the bottom of all pages of my application. How can I do that? Also, if using overhang.js for this scenario is not approapriate, kindly suggest me the correct approach.

Thanks in advance!

Upvotes: 0

Views: 253

Answers (2)

Yesha
Yesha

Reputation: 678

It turns out the solution was quite simple. I simply had to put the overhang script from home page to application.html.erb file.

Upvotes: 1

Sikandar Tariq
Sikandar Tariq

Reputation: 1316

Just put a div in your layout/footer partial

<div id="notification-element"></div>

and add this js script code.

alert($("notification-element").data("overhangConfirm"));

hopefully that'll do the work for you

Upvotes: 0

Related Questions