Search code examples
jqueryjquery-selectorswildcardwysihtml5

May I use many wysiwyg jquery selectors with textareas?


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/


Solution

  • 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();
    });