0

I'm using bootstrap-wysihtml5-rails in my rails app, all is working well until I attempt to use a wildcard selector.

For example:

Javascript

$('[id*=some-textarea]').wysihtml5();

HTML

<textarea id="some-textarea1" placeholder="Enter text ..."></textarea>
<textarea id="some-textarea2" placeholder="Enter text ..."></textarea>

Does not work on Chrome Version 22.0.1229.94, console is saying "Uncaught Error: NOT_FOUND_ERR: DOM Exception 8"

Safari show's the wysiwyg controls on some-textarea1 only.

When I'm explicit, they work fine

$('#some-textarea1').wysihtml5();
$('#some-textarea2').wysihtml5();

But the number of textarea's on my rails form are dynamic, so I'd really like to use a wildcard, if at all possible?

Is this an issue with wysiwyg.js? As a simple css background change works...

Here's an example: http://jsfiddle.net/8PBwA/3/

gef
  • 7,025
  • 4
  • 41
  • 48

2 Answers2

1

I'm going to go out on a limb here (from a quick look at the plugin source) and say that this JS plugin does not support a collection as an argument.

You can use a for loop.

$('[id*=some-textarea]').each(function() {
     $(this).wysihtml5();
});
snowangel
  • 3,452
  • 3
  • 29
  • 72
Julia McGuigan
  • 624
  • 1
  • 7
  • 16
0

Try encasing your selector in Double-Quotes.. Check if that helps

$('[id*="some-textarea"]').wysihtml5();

Also you can try assigning a single class to all those text areas..

<textarea id="some-textarea1" class="w5text" placeholder="Enter text ..."></textarea>
<textarea id="some-textarea2" class="w5text" placeholder="Enter text ..."></textarea>

$('.w5text').wysihtml5();

OR

var count = 30;

for(var i = ;i<= count ; i++){
   $('#some-textarea'+ count).wysihtml5();
}
Sushanth --
  • 55,259
  • 9
  • 66
  • 105
  • yeah I've tried both of those. http://jsfiddle.net/8PBwA/6/ No luck :( I've also tried start with & end with selectors – gef Oct 20 '12 at 02:20
  • If you know the number of text boxes you have on page .. You can try running a for loop.. – Sushanth -- Oct 20 '12 at 02:22