jQuery in 4.0 RC 2 and $telerik is not defined
We have upgraded to SF 4.0 RC 2 and now, 2 custom control widgets that we made, lock-up the edit-a-page screen. We can drag them to a drag-widgets-here box, and publish the page, but when we open the page, in the edit-a-page screen for editing, that screen (the edit-a-page screen) pretty much has none of the functionality that it should have: the Publish button does not appear, the buttons across the top which are visible do nothing, and you cannot drag any of the widgets - neither SF ones, nor our custom ones. AND Firebug shows us that the page gets an error: "$telerik is not defined."
We used the js from the tutorial here
www.sitefinity.com/.../writing-the-javascript-for-the-dialog.aspx
So to reproduce the error you should be able to try to put a custom control widget, that you created based on that tutorial, is a SF 4.0 RC 2 version of Sitefinity.
Is it possible that the jQuery and/or javascript in SF 4.0 RC 2 was changed in a way to create this issue?
Thanks
Phil
Hi Phil,
I had this same problem (even before RC2). My work around is to load the jquery files in the code behind of my custom master page template file. When I load them I check to see if I'm in design mode and if I am I don't load the jquery scripts. It means in the backend all my custom js functionality doesn't work but at least it doesn't kill the backend and disable admin functionality (the edit buttons for content areas disappear).
protected override void OnPreRender(EventArgs e)
// Register Client Scripts
if (!this.IsDesignMode())
this.Page.ClientScript.RegisterClientScriptInclude("jquery", "/custom/scripts/jquery.js");
this.Page.ClientScript.RegisterClientScriptInclude("jqueryui", "/custom/scripts/jquery-ui.min.js");
base.OnPreRender(e);
Hmmmmm. Well, I dont want to give up that functionality in the edit-a-page screen. But more importantly, doing without the js file is not at all an option for me because it is central to getting the values, which the user has entered, from the control designer, to the widget ascx in the edit-a-page screen.
So, Sitefinity, I still need advise on this.
Phil.
Perhaps check Eric's solution here
http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/jquery-plugins-and-or-authoring-custom-jquery-functions-not-supported.aspx
He had a case where jQuery was being re-defined and custom functions were lost, perhaps this is similar to what's happening in your case.
Phill
Thanks Phil. Eric's solution looks interesting. I was not able to apply it and I have a question in to him.
Eric calls his solution hacky and hopes for an answer from SF.
I also, would like SF to weigh in on this and give us a solution. Even though your situation, Phil, was before RC 2, there are 3 of us that had everything working fine before RC 2 but now are having this $telerik undefined issue.
Sitefinity, please advise.
I was wondering about this myself...in the javascript samples they use "jQuery" as the prefix instead of $ or $telerik
Okay, I just encountered this error now...This works for me...
$(document).ready(
function
()
if
(!$telerik.$ ==
true
)
$telerik.$ = jQuery;
);
I applied Steve's fix and was very happy that I could go to the edit-a-page screen and back to the page list screen over and over w no errors and all the functionality on all screens was fine.
Then I hit the Preview button and I got an error: "$ is not defined". In Preview, it is erroring on the line of code that is the fix for the edit-a-page screen.
$(document).ready(function()
Is jQuery loaded on your page (not the backend)?
What's the script error?