Contents of "SimpleScriptView" widget not appearing in designer
Hello,
We are developing a Sitefinity widget that requires external scripts, so we inherit from SimpleScriptView so that we can register that script reference.
This works fine on the actual site, but in the designer, the control's contents are not displayed. There is a PUT request made to the ZoneEditorService that should retrieve the control's HTML, but the "Html" field in the JSON response is always coming back null. Publishing the page and going into the designer again displays the widget, but it does not update to reflect changes made in the widget's designer.
This seems to be true of all widgets that inherit from SimpleScriptView. Is there a preferred way of including an external JavaScript file, or some way of making a widget that derives from SimpleScriptView work as expected?
Thanks,
Chris
Hello Chris,
You can reference the external javascript with
private const string scriptPath = "ScriptViewControl.Resources.MyControl.js";
private const string controlScript = "Telerik.BlogsContentSelectorsDesignerView.js";
[assembly: WebResource("ScriptViewControl.Resources.MyControl.js", "application/x-javascript")]
<
sf:JavaScriptEmbedControlrunat
=
"server"
ID
=
"jQueryLink"
ScriptEmbedPosition
=
"Head"
</
sf:JavaScriptEmbedControl
>
<
sf:JavaScriptEmbedControlrunat
=
"server"
ID
=
"jQueryUILink"
ScriptEmbedPosition
=
"Head"
</
sf:JavaScriptEmbedControl
>
<
sf:JavaScriptEmbedControlrunat
=
"server"
ID
=
"JavaScriptEmbedControl6"
Url
=
"~/RTC_Scripts/series.js"
ScriptEmbedPosition
=
"Head"
>
</
sf:JavaScriptEmbedControl
>
<
sf:JavaScriptEmbedControlrunat
=
"server"
ID
=
"JavaScriptEmbedControl5"
Url
=
"~/RTC_Scripts/jquery.anythingslider.js"
ScriptEmbedPosition
=
"Head"
>
</
sf:JavaScriptEmbedControl
>
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Hi,
Thank you for the reply -- unfortunately, that does not resolve the problem. I am including the JavaScript as an embedded resource (included in the AssemblyInfo) and it is working at run-time. The problem is that the control does not refresh in the back-end until I click "Publish", unlike other controls, which refresh immediately.
Thank you,
Chris
Hi Chris,
Thank you for the clarifications. To refresh the designer immediately refer to this tutorial and sample code of the designer javascript files. In the video you can see the control refreshes the updated content immediately.
// bind designer properties back to widget
controlData.Name = jQuery("#txtName").val();
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>