开发者

Can I get the original textarea id from within jwysiwyg?

I have some textareas:

<textarea id="temp1">Hello</textarea>
<textarea id="temp2">Hello</textarea>
...

and I initialize jwysiwyg on them:

$开发者_开发知识库('#temp1').wysiwyg();
$('#temp2').wysiwyg();

I also have a custom button for saving the content. Now how can I get a hold of the original textarea dom element? (I need to distinguish between several occurances of jwysiwyg here.)

function Wysiwyg() {
  this.controls = {
    save: {
      exec: function () {
        // Magically find the id of the original textarea plx.
        ...

Thanks...


$('#temp').wysiwyg($(this));

function Wysiwyg(textarea) {
  this.controls = {
    save: {
      exec: function () {
        $(textarea).val(); //return selected text area value
        // Magically find the id of the original textarea plx.
        ...

When you run the function for wysiwyg, send the selected element through to the function and call the jquery within that function from the passed in variable...

You must remember you can only use id once on the document if you have multiple text areas you can put this for applying css, if you use the $(this) reference on a clicked item then you do not need to call it by anything else:

<textarea class="tArea">Hello</textarea>
<textarea class="tArea">Hello</textarea>
 $('textarea.tArea').wysiwyg($(this));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜