How to set value of textarea - not working with class

Hi..
I'm trying to set a value of a TEXTAREA.

  <textarea  id="notes" name="notes" class="editor" rows="3" cols="60"></textarea><br/>
                                                  
By doing the follwing

   $(".modal-body #notes").val(' CRAP! ');

Does not work

But


If I remove the class='editor' from the HTML, like this.  It works!!   Any Ideas?

  <textarea  id="notes" name="notes"  rows="3" cols="60"></textarea><br/>
LVL 1
JElsterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anthony PangilinanDeveloperCommented:
Is there perhaps another bit of JS that is bound to the 'editor' class?  You can try using this (http://sprymedia.co.uk/VisualEvent/) to see if there are multiple functions bound to your element.
0
GaryCommented:
Have a live link or can you post the rendered HTML for that code.
The class shouldn't make any difference.
0
JElsterAuthor Commented:
Seems this is blocking it
Any ideas?

<script>
        tinymce.init({
              selector:'textarea.editor',
              force_br_newlines : true,
                  force_p_newlines : false,
                  forced_root_block : '', // Needed for 3.x
                  plugins: "code"
              });
</script>
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

GaryCommented:
Tinymce doesn't actually use a textarea, it converts it to an editable div
So are you actually using TinyMCE or a textarea?
0
Anthony PangilinanDeveloperCommented:
Is that ' tinymce.init()' block executing fine?
0
JElsterAuthor Commented:
I think so.. it changes the textarea creates text options. I don't know a thing about it.
0
Anthony PangilinanDeveloperCommented:
From what I've read, it looks like after tinymce is initialized, you can only interact with your textarea using tinymce.  Maybe something like one of these would work:

$(tinymce.get('.modal-body #notes')).val(' CRAP! ');

Open in new window


tinymce.get('.modal-body #notes').setContent(' CRAP! ');

Open in new window

0
JElsterAuthor Commented:
tinymce is always undefined
??
0
Anthony PangilinanDeveloperCommented:
Is the tinyMCE library included before the function call?
0
JElsterAuthor Commented:
Yes..
like this
<script src="js/tinymce/tinymce.min.js"></script>
<script>
    tinymce.init({
        selector: 'textarea.editor',
        force_br_newlines: true,
        force_p_newlines: false,
        forced_root_block: '', // Needed for 3.x
        plugins: "code"
    });
</script>
0
Anthony PangilinanDeveloperCommented:
It looks like you need the jQuery build of tinyMCE in order to use jQuery calls that reference tinyMCE.  That second suggestion I gave shouldn't have the same problem, but maybe I got something wrong in the syntax.  This page may help http://www.tinymce.com/wiki.php/API3:method.tinymce.Editor.setContent.
0
JElsterAuthor Commented:
Add the Jquery.. can set the value .. shows it's set in the debugger
but does not display in the textarea
????

      $('.modal-body #notes').val(' this sucks..');
0
Anthony PangilinanDeveloperCommented:
tinymce.triggerSave();

Open in new window


or

tinymce.get('.modal-body #notes').save();

Open in new window

0
JElsterAuthor Commented:
undefined not a function?
0
Anthony PangilinanDeveloperCommented:
Sorry, I may have the syntax wrong again.

http://www.tinymce.com/wiki.php/API3:method.tinymce.Editor.save
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.