+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Pure MVC / Jquery

Pure MVC / Jquery

5 posts, 0 answered
  1. Ruth
    Ruth avatar
    25 posts
    Registered:
    17 May 2012
    15 Sep 2015
    Link to this post

    Including jquery on a Pure MVC layout page breaks backend editing when using the prescribed method:

    @Html.Script(ScriptRef.JQuery)

    This is due to the followng script error:  

    TypeError: jQuery.validator is undefined

    Can anyone advise on how this can be done? Has anyone actually used Pure MVC on a real project? 

     

  2. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    15 Sep 2015 in reply to Ruth
    Link to this post

    Yeah on multiple projects, haven't had an issue

     Try @Html.Script(ScriptRef.JQuery, "top") ...or whatever all your other widgets views have it set to.

    Is it on a specific widget, you on the latest version...?
  3. Ruth
    Ruth avatar
    25 posts
    Registered:
    17 May 2012
    16 Sep 2015
    Link to this post

    Thanks for your response.

    I'm adding jquery to the template not widget, this all works as expected but its the fact that once I create a page based on the template I'm unable to edit in the backend due to the error mentioned above.

    I'm using the trial version of 8.1.5810.0 in order to evaluate Pure MVC with a view to using it on an upcoming project.

  4. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    16 Sep 2015 in reply to Ruth
    Link to this post

    This is what I do

     

    @if (!Util.IsEditMode)
    {
        @Html.Section("jquery")
        @Html.Script(ScriptRef.JQuery, "jquery")
    }
    @Html.Section("bottom")

    I then do a find\replace in my project for  @Html.Script(ScriptRef.JQuery, "top") to @Html.Script(ScriptRef.JQuery, "jquery")

     (this is the Util method)

    namespace SitefinityWebApp
    {
        public static class Util
        {
            public static bool IsEditMode
            {
                get
                {
                    return SystemManager.IsDesignMode;
                }
            }
        }
    }

    This puts jQuery right at the bottom of the page, by default it's gonna load at the top.  It's injected in page edit mode, so this loads the once I specify only in Live move where I want. 

     

    Ruth said:

    Thanks for your response.

    I'm adding jquery to the template not widget, this all works as expected but its the fact that once I create a page based on the template I'm unable to edit in the backend due to the error mentioned above.

    I'm using the trial version of 8.1.5810.0 in order to evaluate Pure MVC with a view to using it on an upcoming project.

  5. Velizar Bishurov
    Velizar Bishurov avatar
    143 posts
    Registered:
    23 Sep 2016
    18 Sep 2015
    Link to this post
    Hi,

    Here's a simplified version of Steve's approach:

    @if (!SystemManager.IsDesignMode)
    {
        @Html.Script(ScriptRef.JQuery, "top")
    }

    And here's what we use in the default templates:

    @* Inline editing scripts and helpers. They should be available only when inline editing is possible. *@
    @if (Html.ShouldRenderInlineEditing())
    {
        @Html.Script(ScriptRef.MicrosoftAjax, "top")
        @Html.Script(ScriptRef.MicrosoftAjaxCore, "top")
        @Html.Script(ScriptRef.JQuery, "top")
     
        @Html.Script(Url.EmbeddedResource("Telerik.Sitefinity.Resources.Reference", "Telerik.Sitefinity.Resources.Scripts.jquery.ba-outside-events.min.js"), "top")
        @Html.Script(ScriptRef.KendoAll, "top")
        @Html.Script(Url.EmbeddedResource("Telerik.Sitefinity.Resources.Reference", "Telerik.Sitefinity.Resources.Scripts.RequireJS.require.min.js"), "top")
        @Html.InlineEditingManager(false)
    }

    Regards,
    Velizar Bishurov
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
5 posts, 0 answered