15.08.2013 Views

Ektron® eWebEditPro Developer's Reference Guide

Ektron® eWebEditPro Developer's Reference Guide

Ektron® eWebEditPro Developer's Reference Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Integrating <strong>eWebEditPro</strong> Using JavaScript<br />

When such an action occurs, Internet Explorer fires an onbeforeunload event,<br />

which saves the content to the hidden field. If you want to intercept the event and<br />

let the user decide whether or not to save the content at that time, use the<br />

following code. Note that the onbeforesave method is inserted prior to the page<br />

create event.<br />

<strong>eWebEditPro</strong>.onbeforesave = MySaveCheck;<br />

<strong>eWebEditPro</strong>.create("myeditor", "100%", "90%");<br />

Then, insert the following function on the page to detect whether to allow the<br />

editor to save. You do not want to never save because that would mean that new<br />

content is never saved.<br />

// Return false to abort the save.<br />

function MySaveCheck()<br />

{<br />

if(ConditionsAllowSave())<br />

return(true); // true allow the save to continue<br />

else<br />

return(false); // false stops the save<br />

}<br />

Finally, if you want suppress the warning message about the save, use the<br />

following code.<br />

<strong>eWebEditPro</strong>Messages.confirmAway = null;<br />

Saving from One Instance of the Editor<br />

The <strong>eWebEditPro</strong>.save method saves all instances of the editor on the page. To<br />

save just one, use <strong>eWebEditPro</strong>.instances[n].save(). The n within<br />

square brackets is either the name of the editor used when creating it (for<br />

example, <strong>eWebEditPro</strong>.create("EditorName", ...)) or an index number<br />

(0, 1, 2, etc., where 0 is the first editor created).<br />

See Also: “Appendix A: Naming the <strong>eWebEditPro</strong> Editor” on page 576.<br />

For example<br />

<strong>eWebEditPro</strong>.create("Summary", 700, 200);<br />

<strong>eWebEditPro</strong>.create("Teaser", 700, 300);<br />

<strong>eWebEditPro</strong>.create("Desc", 700, 400);<br />

...<br />

<strong>eWebEditPro</strong>.instances["Desc"].save();<br />

or<br />

<strong>eWebEditPro</strong>.instances[2].save();<br />

Alternatively, you can retrieve content by passing an object to the save method.<br />

To do this, set the object’s value property to receive the content.<br />

For example<br />

var objContent = new Object();<br />

objContent.value="";<br />

<strong>eWebEditPro</strong>.save(objContent);<br />

.objContent.value now stores the content.<br />

<strong>Ektron®</strong> <strong>eWebEditPro</strong> Developer’s <strong>Reference</strong> <strong>Guide</strong>, Release 5.1, Revision 1 574

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!