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

[Solved] windows open script error

0 Answers 35 Views
Window
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Punprom
Top achievements
Rank 1
Punprom asked on 29 Feb 2012, 12:28 AM
Hi,
First, I am fairly new to Telerik Window and also MVC & Razor.
I am trying to create a index view page for a products category with a window popup directing to creating a product category.
On the view page, I have a grid view which populate items correctly and I have a <a> tag to activate javascript onclick event. The page is as code below,

<h2>Product Categories</h2>
    
        @{    Html.Telerik().Window()
                .Name("Window1")
                .Title("Add New Category")
                .LoadContentFrom("Create","Category")
                .Width(540)
                .Modal(true)
                .Visible(false)
                .Draggable(true)
                .Render();    
       
        }

        <a onclick="openWin()" style="margin:0 20px;">add new category</a>
        <script type="text/javascript">
             function openWin() {
                $('#Window1').data('tWindow').center().open();
             };

        </script>
     
        <div style="margin: 5px 20px;width:65%">
        @{
             Html.Telerik().Grid(Model)
                .Name("grdCategories")
                .Columns(cols =>
                {
                    cols.Bound(c => c.CategoryName).Title("Name").Width(180);
                    cols.Bound(c => c.Description).Title("Description").Width(320);
                    cols.Template(
                        @<text>
                          <div style="text-align:center; width:100%">
                            @Html.ActionLink("edit", "Edit", "Category")
                            &nbsp
                            @Html.ActionLink("delete", "Delete", "Category")
                          </div>  
                        </text>
                     );
                })
                .Pageable()
                .Scrollable(scrolling => scrolling.Height(250))
                .HtmlAttributes(new { @style="width:100%" })
                .Render();
         
         }
      
        </div>
       
When I tried to get click the <a> tag I get script error stating the javascript object undefined. As a newbie I don't know why?.
Note, I do have the script link on my master page, ( _Layout.cshtml) using,
<script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script>

Thanks for your help.

Punprom.
Tags
Window
Asked by
Punprom
Top achievements
Rank 1
Share this question
or