0

I have a college project in which i am using ace editor on a webpage. https://github.com/ajaxorg/ace

Ace editor customizes tag to look like a editor. I can extract its value usign jquery .val() function or editor API but the source code looses its syntax. For example if the code is :

System.out.printls("Enter number");
int value = ScannnerObj.nextInt();

The extracted values looks like :

System.out.printls("Enter number");int value = ScannnerObj.nextInt(); //All in one line

I have to extract this value from editor and save it in database I am using Django for it. Later I also want to retrieve it in such that the Program Syntax is not altered.

Can anyone tell my correct way to achieve this. I am missing some link in here. Thanx in advance :)

11
  • 1
    How are you trying to confirm that the extracted values don't have line breaks? Normal html will not display line breaks when viewed through the browser as plain text.
    – Kevin B
    Feb 22, 2012 at 16:36
  • I pass the extracted value using POST method the Django View which handles it and saves it in database.I then get the value from database and view it using python interactive shell
    – rockvilla
    Feb 22, 2012 at 16:40
  • 1
    I'm with Kevin--if you're printing the data back out in HTML the line breaks won't display. Wrap the output in a <pre> tag, if that's the case. Feb 22, 2012 at 16:42
  • Regarding your last comment, does the data appear to have line breaks when POSTing the data to Django? Are you using a native method of the Ace editor that might be stripping away line breaks? Feb 22, 2012 at 16:44
  • i use this code to extract data : var myDiv = document.getElementById("editor"); var program = myDiv.textContent;
    – rockvilla
    Feb 22, 2012 at 16:46

1 Answer 1

0

Ok guys I found the solution for it :) use the following code to render ace editor

editor = ace.edit("editor"); 
not 
var editor = ace.edit("editor"); //(not to write var)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.