Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8340733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:15:38+00:00 2026-06-09T05:15:38+00:00

I’m looking at the Sharre social mediq jquery plugin http://sharrre.com/# Below is an example

  • 0

I’m looking at the Sharre social mediq jquery plugin http://sharrre.com/# Below is an example of how to use it.

simple_jquery_social.js example:

$('#sharrre').sharrre({
share: {
  googlePlus: true,
   facebook: true,
  twitter: true
 },
url: 'http://sharrre.com'

})

So in normal rails usage, I would add the above in my assets directory (along with the sharrre jquery lib stuff), put a ‘div id=sharrre’ tag in my view, and I’d be done. But I would like to make a rails helper function to use in my .html.erb view template and dynamically decide whether or not to display google plus, for example. So I would want something like:

<%= my_helper :googlePlus=>false %>

Then my environment should know that the googlePlus variable in the jquery code above would now be false, and hence the googlePlus button would not be displayed. **The whole point is to to control a lot more options available in the jquery plugin dynamically thru Rails. But to do that I need to be able to set jquery variables dynamically through Rails. I realize the above example is trivial because I could just change the jquery variable by hand, but by doing it through Rails, I could also set the url param dynamically, which is something I want to be able to do so people can recommend particular pages.

What is a good mechanism for accomplishing this, or is it even possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:15:39+00:00Added an answer on June 9, 2026 at 5:15 am

    Create a helper that takes an ID, a URL and a hash of options as a param.

    Then the helper generates a mix of JS and html, outputting both the JS code and the div that needs

    def sharrre_tag(div_id, url, options = {})
      div_str = "<div id='#{div_id}'></div>".html_safe
      js_str = "<script>".html_safe
      #Add code to append specific js code and test all option existence and append time to js_str
      js_str += "</script>".html_safe
      return js_str + div_str
    end
    

    And in the view just call your helper with the right params

    Option 2. Separate JS from HTML

    If you want to achieve this, you could write a JS code in your separate JS file that’ll take each element with a class sharrre_div. For each one, it’ll check if specific html data attributes exist : data-sharrre-googlePlus, data-sharrre-twitter, data-sharrre-url etc … this option relies heavily on JS

    JS : Encapsulate it in a body onload event

    var sharrre_attr_array = ['data-sharrre-googlePlus', 'data-sharrre-facebook', 'data-sharrre-twitter'];
    $('.sharrre_div').each(function(index){
        var share_hash = {};
            var current_div = $(this);
            $.each(sharrre_attr_array, function(index, element){
    
              if(current_div.attr(element)){
                    share_hash[element.split('data-sharrre-')[1]] = true;
                }
          });
        $(this).sharrre({
              share: share_hash
                ,url: $(this).attr('data-sharrre-url')
            });
    
    });
    

    All your helper has to do is then create a div like this :

    <div class='sharrre_div' data-sharrre-googlePlus='1' data-sharrre-twitter='1' data-sharrre-url='<%=request.url%>' data-sharrre-facebook='1'></div>
    

    Shouldn’t be too hard to write 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.