tags:

views:

56

answers:

3

I have page with 5 divs and i want to open editor on click of selected div .

And div content will come into the editor what i will do for this.

is there any j query for this.

+1  A: 

Check out NicEdit or TinyMCE. Both can be configured to edit the content in a div or any other element.

Matthew
A: 
    CSS:
    .hidden{
       display:none;
    }

    <div id="container">
      <div id="div1" class="edit-div"><div class="editor hidden"></div><div class="content"></div></div>
      <div id="div2" class="edit-div"><div class="editor hidden"></div><div class="content"></div></div>
      <div id="div3" class="edit-div"><div class="editor hidden"></div><div class="content"></div></div>
      <div id="div4" class="edit-div"><div class="editor hidden"></div><div class="content"></div></div>
      <div id="div5" class="edit-div"><div class="editor hidden"></div><div class="content"></div></div>
    </div>

var xeditorChange = function(el)
{
  if ($(el).length>0)
  {
  $(el).find(".content")
    .empty()
    .html(editor.getText())
    .removeClass("hidden");

  $(el).find(".editor")
   .empty()
   .addClass("hidden");
  }
};

$(function(){
  $(".edit-div").click(function()
{
 xeditorChange( $("#container").find(".editing") );

 editor.addText($(this).find(".content").html());
 $(this).find(".content").addClass("hidden");
 $(this).find(".editor").removeClass("hidden");

 //show editor in  $(this).find(".editor")
});

  //on save text in editor add the html with reverse function

});
andres descalzo
Thanks for reply but it didn't work for me.Do you have any other way to do this.
Pankaj Mishra
I do not know what editor you have, but as far as I probe the script works. You would have to adapt to the editor that you use the functions editor.getText() and editor.addText(...)
andres descalzo
A: 

Do you want to edit the contents in place? Have you looked at the Jeditable plugin?

fudgey
Thanks Great answer but but i need an editor also.if i will click then it will come in edit mode with text editor.
Pankaj Mishra
Then I would use the suggestions by Matthew! :)
fudgey