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 6337825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:19:30+00:00 2026-05-24T19:19:30+00:00

i have a problem with my jquery but unable to find why. When i

  • 0

i have a problem with my jquery but unable to find why.
When i click for the first time on my link, nothing happen. On the second click, my link work. here is my code.

aplication_helper.rb
def link_to_share(name, url)
  link_to_function(name, "share_link(name, url)")
end

my jquery file

function share_link(link, url)
{
  $(link).click(function() {

    window.open('http://www.facebook.com/sharer.php?u='+ url, 'popupwindow', 'height=430,width=500')
  });
}

my view

<%= link_to_share 'Share', request.url %>

If i change my jquery function like

function share_link(link, url)
{
  $(link).live('click', function() {

    window.open('http://www.facebook.com/sharer.php?u='+ url, 'popupwindow', 'height=430,width=500')
  });
}

the script stop working.

in my Firebug debugger, i have no error on the first click, and in the second try with the live function, no error too.

I use jquery-uij from gemfile.

thanks.

  • 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-05-24T19:19:30+00:00Added an answer on May 24, 2026 at 7:19 pm

    To make your code work, remove the click handler

    $(link).live('click', function() {
    }
    

    And just leave

    function share_link(link, url)
    {
        window.open('http://www.facebook.com/sharer.php?u='+ url, 'popupwindow', 'height=430,width=500')
    }
    

    You don’t need to define the click handler, because you’re using the link_to_function helper. The link_to_function helper, just calls the function you entered when you click that link.

    For more information, check out the documentation. I didn’t know about this helper, thanks for asking this question.

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

Sidebar

Related Questions

I have problem with Jquery UI dialog,when i click the button the first time,
I have a problem of jQuery's live() function not working with click, mousedown but
I have a problem with jQuery click event handling. Here's my code: $j(#btn_renommer_groupe).click(function(){ document.forms['creation_edition_groupe'].reset();
I am using the jQuery disable on submit plug-in but I have a problem.
I'm working with a demo of two sortable jquery lists... but have a problem
I created a jQuery plugin but I have a problem, I use the following
I have a problem with jQuery: when i click in Home Page on a
Hey, sorry to be such a nuisance, but I have another jQuery problem. Same
I have a jQuery problem that I can't seem to work out on my
I have a little problem with jQuery UI 's droppable component, but I'm not

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.