Search the FirstSpirit Knowledge Base
Hi,
I have a problem with a fs_button and JS code as param
$CMS_VALUE(
fsbutton(
editorName:"suggestedDate",
parameter:{ "date":"$('date').get('value')".plain }
,
callback:"refreshPage"
)
)$
the button will be not rendered and i got on js console this error
SEVERE: [encodeButtons] failed (in 73 ms)!
java.lang.IllegalArgumentException: Element is not serializable: '$('dateFrom').get('value')' (class de.espirit.firstspirit.common.text.PlainString)!
my form button
<FS_BUTTON
name="suggestedDate"
alwaysEnabled="yes"
hFill="yes"
hidden="yes"
icon="fs:ACTION"
noBreak="yes"
onClick="script:kb_suggest_dates"
style="button"
useLanguages="no">
<LANGINFOS>
<LANGINFO lang="*" label="Fixtermin eintragen" description=""/>
</LANGINFOS>
</FS_BUTTON>
In the HTML template set, the FS_BUTTON component is rendered when fsbutton(...) is called and configured for the use of a user-defined text comment:
<input type="text" id="releaseCommentary" />
<div
$CMS_VALUE(
fsbutton(
editorName:"releasePageButton",
parameter:{
"commentaryText":"document.getElementById('releaseCommentary').value".plain
},
callback:"refreshPage"
)
)$></div>
The JavaScript and FS_BUTTON instance are output only in a ContentCreator preview. |
The HTML code contains the definition for the refreshPage(...) JavaScript function that is called after clicking on the FS_BUTTON and the subsequent execution of the releasePageScript template script.
Hi Antonio,
did you try to log the return of $('date').get('value')? According to the error I'd guess the value just isn't serializable cause it's complex, null, undefined or sth. else.
Maybe just try sth. like "typeof($('date').get('value'))".plain cause typeof always returns a String. If you don't get the error anymore the issue seems to be realted to the value of $('date').get('value')
Best regards
Felix
Hi Felix,
Thx, I found an alternative solution in top.WE_API.Common.execute("script:
<script type="text/javascript">
function create_event(){
top.WE_API.Common.execute("script:create_event",
{
"convert": true,
"kb_type": "$CMS_VALUE(#global.section.template.uid)$"
},
function(result){
refreshPage(result);
}
);
}
</script>
<button onclick="create_event();" class="fs-button fs-button-button">
<span class="fs-button-iconlabel ">
<span class="fs-button-icon"><span data-fs-resource-icon="ACTION"></span></span>
<span class="fs-button-label middle">In eine Veranstaltung umwandeln</span>
</span>
</button>