Weird Error when Adding ShareThis Hovering Buttons to Rails

Hi all,

I am trying to add the ShareThis Hovering buttons to my Rails 3
application but have no luck. I got the embed code from
ShareThis. In order to
prove that the problem is specific to Rails, I put the same code into
a HTML file outside the rails app and also a pure HTML file inside the
public directory (without routed to controller) of my rails app. It
turns out that the HTML file outside the rails app works but the one
inside the public directory threw an error “Uncaught TypeError: Cannot
read property ‘length’ of undefined” at load.js:1 (obtained by google
chrome error console).

Any help will be appreciated!

Regards,
Sheng-Loong.

Sheng-Loong,

I bet no one wants to have to go to a site, agree to licensing
agreement, and then fill out a form so they can help you with your
problem. The morale of the story is: if you want help, make it easy
for people to see your problem

soldier.coder,

I believe I provided all the information I could in my last email. I
admit that I should attach the source code. So here it is at
ShareThis Hovering Button - Pastebin.com. I put this piece of code (without any
other line of code) into two files - one outside my rails app
directory and another one in the public directory. In the end, only
the one outside the rails app directory works so I believe this
problem is pertaining to the rails framework. Note that I didn’t even
route to a controller to render the view.

I am sorry for not structuring my question properly in the last email.
I am new here, please have mercy on me =)

Regards,
shengloong

On Sep 12, 4:20pm, “soldier.coder” [email protected]

On 11 September 2011 11:57, shengloong [email protected] wrote:

read property ‘length’ of undefined" at load.js:1 (obtained by google
chrome error console).

Try using Firebug in firefox to display the page and see if it shows
any errors. Also check the html is fully valid using the w3c html
validator.

Colin

The problem is with the domain name as loader.js tries to do a split on
the domain name. So if you are hitting the page localhost:3000 which has
the sharethis widget it will not show up as it cannot split localhost.
However if you map your machine(127.0.0.1) to something like a.b then
loader.js can split it and the ShareThis widget will show up.

On 13 September 2011 09:57, shengloong [email protected] wrote:

ShareThis Hovering Button - Pastebin.com. I put this piece of code (without any
other line of code) into two files - one outside my rails app
directory and another one in the public directory. In the end, only
the one outside the rails app directory works so I believe this
problem is pertaining to the rails framework.

JS is client-side code, and nothing to do with Rails. but I would be
looking at the source-code generated by Rails to see if any other
javascript files are being included which might conflict with your
“sharethis” files.

Essentially, I’d be viewing the source of the two files (one Rails
generated and one not) to look for differences, because something in
there is confusing your browsers…