Dynamically changing text in twitter button (rails+jquery) -


ok, have index.html.erb. in have menu, render _menu.html.erb, , div, in render link show.html.erb using show action in controller. link shown <%=link_to h(@link), h(@link) %> (code show.html.erb).

div, in link rendered, refreshed $('#div_with_link').load('controller/show');, @link changes lot.

the problem is, don't know, should put in twitter button text area. want people able share current link. i've tried data-text="<%=@video %>", showing link on webpage, not generated one.

what should do, put generated link in twitter button? suggestions help, thank in advance.

alright, if you're using twitter's default button pretty hard achieve. i'd recommend build your own button , update href attribute link via javascript including mentioned parameters. here's code started:

use instead of twitter button , style accordingly:

<a href="http://twitter.com/share" id="tweet">tweet</a> 

every time load new div, set new url (and other params if want to) e.g. this:

// not knowing app, i'm guessing here: var twitterparams = {      url: <%= url_for(@video) %>,      text: <%= @video.title %>  };  $('#tweet').attr('href', "http://twitter.com/share?" + $.param(twitterparams)); 

you e.g. in piece of html you're returning when you're loading new via ajax.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -