0

Problem with browser in CodeMirror

asked 2011-10-31 11:34:59 +0800

siva477 gravatar image siva477
57

updated 2011-10-31 11:38:45 +0800

Hi,

I am using ZK 5.0.7 version . I have a problem with codeMirror in InternetExplorer and Firefox.

I tried to add code from Listbox to codemirror textarea by using onDoubleClick on Listbox. My problem is....

with Explorer : When i click listItem on listbox, value from listbox is always added at begining of the total entered code. Because cursor is always placed at the begining position of theTextarea.

with Mozilla : At the first attempt of clicking listitem in listbox, value is added and then cursor is going to start position of Textarea.

Code is working fine on google Chrome browser.


MY CODE:

javascript function:
function addStringContent(strContent) {
 	zk.Widget.$(jq('$codeMirror'))._editor.replaceSelection(strContent+" ")${cursor};
}

ZUL file code:

<listbox id="listbox" mold="default" height="100%" w:onDoubleClick="addStringContent(this.getSelectedItem().getLabel())" ></listbox>
<codemirror id="codeMirror" syntax="js" ></codemirror>

Please send me any suggestions to solve my issues on these browsers....

Thanks & Regards,
Siva Kumar

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2011-11-01 02:52:43 +0800

vincentjian gravatar image vincentjian
2245 6

Hi Siva,

I don't familiar with CodeMirror. However, I tried with the following javascript code and it works fine in IE, Firefox and Chrome.

function addStringContent(strContent) {
 	zk.Widget.$(jq('$codeMirror'))._editor.insertIntoLine(0, "end", strContent+" ")${cursor};
}

link publish delete flag offensive edit

answered 2011-11-01 06:24:23 +0800

siva477 gravatar image siva477
57

updated 2011-11-01 06:32:16 +0800

Hi vincentjian,

Thanks for giving me your valuable suggestion.......

I tried your code. But it is not working fine. It takes position of cursor always at the end. Before set the value into codeMirror, i set the cursor position by mouse click. But it takes end position of the line.

And also it is not working for replacing the selected text, what i want to replace in codeMirror.

MAIN PROBLEM: I got the problem in this . CodeMirror doesnot store the cursor position in history. It stores correctly , only when value entered through keyboard or mouse in manually . This problem is mainly in IE Browser

Thanks & Regards,
Siva Kumar

link publish delete flag offensive edit

answered 2011-11-01 06:54:11 +0800

siva477 gravatar image siva477
57

updated 2011-11-01 06:54:44 +0800

Hi,

Can any one say about , how to set the cursor position dynamically by any method in codemirror using javaScript code.

Thanks & Regards,
Siva Kumar

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-10-31 11:34:59 +0800

Seen: 242 times

Last updated: Nov 01 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More