[opencms-dev] javascript in resource-type fails to run after property edit and save from workspace
Patric Dosch
patric.dosch at virtual-identity.com
Fri Feb 24 11:31:45 CET 2017
This is the normal behavior… javascript is „removed“ when the edited content is replaced.
You can use enableReload
http://documentation.opencms.org/opencms-documentation/typical-tasks/writing-jsps/interesting-el-expressions/
Placing ${cms.enableReload} somewhere in your formatter will result in an automatically page reload when content is edited (or moved to a different container).
Von: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] Im Auftrag von Clement Wee
Gesendet: Freitag, 24. Februar 2017 11:06
An: opencms-dev at opencms.org
Betreff: Re: [opencms-dev] javascript in resource-type fails to run after property edit and save from workspace
The relevant formatter jsp is:
<%@page buffer="none" session="false" trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<cms:formatter var="content">
<c:set var="svg" value="image-${cms.element.id<http://cms.element.id>}"/>
<div class="margin-bottom-30">
<div class="panel">
<h3>${cms.element.id<http://cms.element.id>}</h3>
</div>
<div class="image" id="${svg}">
<!--<svg width="400" height="110">
<rect width="300" height="100" style="fill:${content.value.BGColor};stroke-width:3;stroke:rgb(0,0,0)">
Sorry, your browser does not support inline SVG.
</rect>
</svg>-->
</div>
<script>
var svg = d3.select("#${svg}").append("svg").attr({"width":"400", "height":"110"});
var rectStyle = "fill:${content.value.BGColor};stroke-width:3;stroke:rgb(0,0,0)";
var rect =
svg.append("rect")
.attr("width", 300)
.attr("height", 100)
.attr("style", rectStyle);
</script>
</div>
</cms:formatter>
On Fri, Feb 24, 2017 at 6:00 PM, Clement Wee <clement at elixirtech.com<mailto:clement at elixirtech.com>> wrote:
Hi OpenCMS Admin,
I am a new user of OpenCMS who is developing a module for a client who uses OpenCMS.
I have deisgned a simple resource-type to test out D3.JS library.
I coded in an inline script within the resource-type JSP itself, because I don't know whether EL is supported in Head Includes Inline javascript.
When I first load a page with an element instance of the module, the SVG created using D3 shows up, but once I edit the properties of that element via the pencil-edit and save, the SVG disappears, only showing up again when I refresh the page.
Can you help me resolve this issue?
Regards,
Clement Wee
Singapore
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20170224/110ba710/attachment.htm>
More information about the opencms-dev
mailing list