This is a migrated thread and some comments may be shown as answers.

jQuery selectable and @(Html.Telerik().ScriptRegistrar())

4 Answers 279 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jaymie
Top achievements
Rank 1
Jaymie asked on 24 Nov 2011, 03:57 PM
Hi,

I have another issue today :)
I have found that using http://jqueryui.com/demos/selectable/ with @(Html.Telerik().ScriptRegistrar()) doesn't work.
As soon as i remove the reference to the ScriptRegistrar, everything starts working.
Is there something that I am doing wrong?

@using (Html.BeginForm())
{
    <ul id="selectable">   
        @foreach (IProfile oProfile in Model)
        {
            <li class="ui-widget-content">@oProfile.UserName</li>
        }
    </ul>   
}       
 
<script type="text/javascript">
    $(document).ready(function () {
        $("ul#selectable").selectable();
    });
</script>

The code above should work with my references to these libraries:

<script src="@Url.Content("~/Scripts/jquery-1.6.2.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.16.custom.min.js")" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/themes/ui-lightness/jquery-ui-1.8.16.custom.css")" />

But as soon as the reference to @(Html.Telerik().ScriptRegistrar().DefaultGroup(group => group.Combined(true).Compress(true))) is added, i get an "Error: Object doesn't support property or method 'selectable'" error....

Please help me :)

/Jaymie

4 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 24 Nov 2011, 04:24 PM
Hi Jaymie,

The problem may be caused by the fact that you have two jQuery instances on the page. You can disable the automatic jQuery registration done by the ScriptRegistrar.

http://www.telerik.com/help/aspnet-mvc/web-assets-working-with-javascript-web-assets.html#jQuery

Regards,
Dimo
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Jaymie
Top achievements
Rank 1
answered on 25 Nov 2011, 12:13 PM
So how do i get around that?
I have my script registrar in my layout, if I change it to the suggested format jquery starts working, but the treeview draggable stops working.
If I have it enabled, then all the jquery stops working.

I tried removing my reference to jQuery and keeping the normal Script Registrar, but that didn't solve anything.

/Jaymie
0
Accepted
Dimo
Telerik team
answered on 25 Nov 2011, 01:34 PM
Hi Jaymie,

Generally, if you disable the ScriptRegistrar's jQuery registration, the only requirement is that your own jQuery registration comes before the ScriptRegistrar in the markup. The other of course is that the jQuery version is compatible with our MVC components.

Do you have some Javascript errors that may point to the right direction? If you need further assistance, you can send us a runnable demo, which exhibits the problem, so that we can take a look.

Regards,
Dimo
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Nikos
Top achievements
Rank 1
answered on 04 Sep 2012, 01:54 PM
I also have the same issue, but
.jQuery(false)
fixed it, why is this necessary?
Tags
General Discussions
Asked by
Jaymie
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Jaymie
Top achievements
Rank 1
Nikos
Top achievements
Rank 1
Share this question
or