jquery-ui.js:12443未捕获的TypeError:无法读取undefined的属性'apply'

时间:2016-11-15 10:06:36

标签: javascript jquery html asp.net-mvc

我已在我的项目中编写此代码,并显示错误:

  

未捕获的TypeError:无法读取未定义的属性“apply”

<UserControl x:Class="OwnDrawingv2.Elements.HostFrame"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:OwnDrawingv2.Elements"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <Style TargetType="{x:Type local:HostFrame}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type local:HostFrame}">
                        <Grid Background="LightBlue" Name="host_grid">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="20"></RowDefinition>
                                    <RowDefinition Height="Auto"></RowDefinition>
                                </Grid.RowDefinitions>
                            <ContentPresenter Name="content" Grid.Row="1" Grid.Column="1" />
                            <CheckBox Grid.Column="0" Grid.Row="0" IsChecked="{Binding Path=test}"> <!--Test prupose-->
                            </CheckBox>
                            <Image Grid.Column="1" Grid.Row="0" Name="attention" Width="30" Height="30"  Source="/attention_icon.png">
                                <Image.Style>
                                    <Style TargetType="Image">
                                        <Setter Property="Visibility" Value="Visible"></Setter>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding Path=test}" Value="true">

                                                <Setter Property="Visibility" Value="Hidden"></Setter>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Image.Style>
                            </Image>
                            <Ellipse Grid.Column="0" Grid.Row="1" Width="10" Height="10"  Fill="Black">
                                <Ellipse.Style>
                                    <Style TargetType="Ellipse">
                                        <Setter Property="Visibility" Value="Hidden"></Setter>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding ElementName=content, Path=IsMouseOver}" Value="true">
                                                <Setter Property="Visibility" Value="Visible"></Setter>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Ellipse.Style>
                            </Ellipse>
                            <Ellipse Grid.Column="2" Grid.Row="1" Width="10" Height="10"  Fill="Black">
                                <Ellipse.Style>
                                    <Style TargetType="Ellipse">
                                        <Setter Property="Visibility" Value="Hidden"></Setter>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding ElementName=content, Path=IsMouseOver}" Value="true">
                                                <Setter Property="Visibility" Value="Visible"></Setter>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Ellipse.Style>
                            </Ellipse>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
</UserControl>

我是否需要为上述代码添加任何库

1 个答案:

答案 0 :(得分:0)

将您的脚本部分放入:

$(document).ready(function(){
    //your script here
});

这样的事情:

<script language="javascript">
   $(document).ready(function(){
     $('#dialog').dialog({
       dialogClass: "no-close",
       buttons: [{
         text: "Ok",
         click: function() {
           $('#dialog').dialog('close');
         }
       }]
     });
   });
</script>

这是有效的jsfiddle