可以't读取'getHTML'未定义的Liferay CK Editor内容

Can't read property of 'getHTML' of undefined Liferay CK Editor content

本文关键字:Liferay CK 内容 Editor getHTML 读取 可以 未定义      更新时间:2023-09-26

我在表单中使用的是C.K编辑器,当我试图在CK编辑器中获取内容时,我会得到无法读取未定义的'getHTML'属性。以下是我的代码:这是我的html:

    <aui:layout>
        <aui:column columnWidth="100">
            <liferay-ui:input-editor width="100%" name='<%= renderResponse.getNamespace()+"healthcontent" %>' height="550"  />
            <aui:input id="content" name="content" type="hidden" value='' />
            <div style="display: none;" id="<portlet:namespace/>healthcontentErrorDiv">
                <div class="portlet-msg-error">
                    Health Report content is required
                </div>
            </div>
        </aui:column>
    </aui:layout>

下面是我的jquery代码:

$jquery(".save-record").click(function(){
        try{
            alert('save record clicked');
            var flag = true;
            var title = $jquery("#<portlet:namespace/>title").val();
            alert("title is "+title);
            if(title == null || title.trim() == ""){
                $jquery("#<portlet:namespace/>titleErrorDiv").show();
                flag = false;
            }else{
                $jquery("#<portlet:namespace/>titleErrorDiv").hide();
            }
        var health_content = window.<portlet:namespace/>healthcontent.getHTML();
        alert("health_content is "+health_content);
        if(health_content != null && health_content.trim() != ""){
            $jquery("#<portlet:namespace/>content").val(health_content);
            $jquery("#<portlet:namespace/>healthcontentErrorDiv").hide();
        }else{
            $jquery("#<portlet:namespace/>healthcontentErrorDiv").show();
            flag = false;
        }
        // Submitting the form
        if(flag){
            $jquery("#<portlet:namespace/>HealthReportsAdministration").submit();   
        }
    }catch (e) {
        alert("Exception raised in HEALTH records11 "+e);
    }
});

window.healthcontent.getHTML();是罪魁祸首。窗口对象中不存在这样的对象。也许你应该做的是,在的后面

<liferay-ui:input-editor width="100%" name='<%= renderResponse.getNamespace()+"healthcontent" %>' height="550"  />

使用

<liferay-ui:input-editor width="100%" name='<%= renderResponse.getNamespace()+"healthcontent" %>' id="<%= renderResponse.getNamespace()+"healthcontent" %>" height="550"  />

然后使用

var health_content = $('#'+<portlet:namespace/>healthcontent);

现在,对这个变量执行任意操作。

我已修改为

<liferay-ui:input-editor width="100%" name="healthcontent" height="550"/>我还修改了inputCssClass,所以我将其更改为cssClass