留言板

A jQuery Question & WYSIWYG Question

Rice Owl,修改在14 年前。

A jQuery Question & WYSIWYG Question

Regular Member 帖子: 177 加入日期: 09-4-24 最近的帖子
Hi all,

I had a question that arose from some weird behavior I hadn't seen before. I'm writing a few JSR-168 Portlets. one of these portlets is comprised of multiple JSP pages, say page1.jsp and page2.jsp. I use the "div" tag and LifeRay's recommended form submission so that only the portlet that's being "submitted" is refreshed. IE:

page1.jsp
<div id="<portlet:namespace />page1">
....
</div>

and page2.jsp
<div id="<portlet:namespace />page2">
...
<div>

My question is, should each JSP page have a DIV tag defined? Would this cause any problems? In the past, when I've written AJAX, the response writes to a <div> tag BUT doesn't write another DIV tag. Should only one of the pages have a div tag defined? in other words, would the HTML structure then contain sub-div tags, and if so, would this create a problem? I of course update the jQuery to reference its own div tag.

I've bene doing this for a while with no issues, but recently have run into an issue with a portlet where I have a WYSIWYG editor (the one that liferay uses, I used a wiki article to do this found on liferay.com).

Here is link to that article http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/How+to+add+a+wysiwyg+html+editor+to+a+portlet

I'm not using any framework such as struts or JSF. Only plain old JSR-168 portlets. The page flow is such that the user goes to page1.jsp, fills out a standard form, then submits. Then user is shown page2.jsp. Page2.jsp has the WYSIWYG editor. I replicated the code found in the article. After page2.jsp is submitted, user is taken back to page1.jsp. This works okay the first time around. The javascript method to set the "hidden" input variable w/ the WYSIWYG editor's HTML content is fine. All is good so far. However, once I do that round one time and if I do it again, it fails. Actually, a few things fail. For one, the javascript method call fails, getHtml(), on the WYSIWYG editor and the javascript error is that getHtml is not a method or something like that. HOWEVER, if I leave the page with the portlet entirely (or hit the refresh button), it'll work again.

That's the reason I ask the first question, I was wondering if the DIV tags on each JSP page were messing with something. Otherwise I don't know why it would work only the first time I go to the page, but not the second time (w/o a page refresh).

Any thoughts?

BTW: I'm using LifeRay 5.2.2 on Tomcat 5.5
Billie Byrne,修改在14 年前。

RE: A jQuery Question & WYSIWYG Question

New Member 帖子: 4 加入日期: 10-2-4 最近的帖子
Hi there,

I'm having the exact same problem. Did you find a solution? It looks like after the second ajax load it's impossible to call method getHTML() on the FCKEditor iframe, making it impossible to send its content to server. Apart from that the FCKEditor seems to work well.

Does anyone have an explanations or workaround? It would be GREATLY appreciated!
Billie Byrne,修改在14 年前。

RE: A jQuery Question & WYSIWYG Question

New Member 帖子: 4 加入日期: 10-2-4 最近的帖子
problem solved by giving a different name to the FCK editor everytime it's loaded

create unique ID
String uniqueFCKId = "infoEditor" +  new Date().getTime(); 


use it to get the content before sending the form
document.getElementById("description").value = window.frames.&lt;%=uniqueFCKId%&gt;.getHTML();


print out the editor using the id
<liferay-ui:input-editor name="<%=uniqueFCKId%>" editorImpl="editor.wysiwyg.default" initMethod="initInfoFCKEditor" />