0

It's exactly what it sounds like. I've got a groovy little plugin in my Rails app that rich-texts field areas. It works fine, except for the fact that two toolbars appear when there should only be one.

$('#user_address').wysihtml5();

If, however, I put beneath it a similar function that refers to nothing:

$('#this_thing').this_is_broken();

Then it fixes the two toolbar issues but breaks all the other jQuery functions I've got going on.

Any ideas? Sounds like a bug to me.

gilly3
  • 87,962
  • 25
  • 144
  • 176
t56k
  • 6,769
  • 9
  • 52
  • 115
  • 1
    You might be including the js file more than once, are you linking to the js file anywhere other than your layout? Perhaps you have require_tree turned on in your application.js? – Noz Nov 08 '12 at 00:14
  • Oh! That's entirely possible. Stay tuned. – t56k Nov 08 '12 at 00:16
  • It now works perfectly. Cheers! – t56k Nov 08 '12 at 00:18

2 Answers2

2

Makes sense - this_is_broken() causes browser to stop parsing the current script. Because javascript is forgiving, the page displays but your code hasn't completely loaded. Figure out where wysihtml5() is being called the second time. Use a lot of console.log()s :)

wheresmycookie
  • 683
  • 3
  • 16
  • 39
0

Thanks to @Cyle Hunter for the answer: I was including the JS file twice.

t56k
  • 6,769
  • 9
  • 52
  • 115