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

[Solved] $("#Details") undefined issue

0 Answers 29 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.
Patrick Jackson
Top achievements
Rank 1
Patrick Jackson asked on 24 Oct 2012, 07:43 PM
Hello All,

This issue is driving me batty.  I have been working on this exact issue all day, with no success.  Can someone please help me figure out where I am going wrong?

Basically what I have going on is that I have a grid, with custom commands, much like this demo, except instead of the window using the .Content property, I want it to load a PartialView that takes a parameter.  Seems easy enough using various example though out the various demos.  Everything I have tried though either results in $("#Details") resulting to [] if I don't use .Render, and if I do use .Render It comes back saying that the resource can not be found.

My Controller:
Public Function Details(ByVal model As ETicketDetailViewModel) As ActionResult
    If model.Version = "Officer" Then
        model.ETicket = EticketService.Details(model.ID)
    ElseIf model.Version = "Violator" Then
        model.ETicket = EticketService.Details(model.ID)
    End If
    Return PartialView(model)
End Function
 
Public Function Details() As ActionResult
    Return PartialView()
End Function

My View:
@code
    With Html.Telerik().Window()
        .Name("Details")
        .Title("ETicket Details")
        .LoadContentFrom("Details", "ETicket")
        .Modal(True)
        .Width(600)
        .Height(500)
    End With
end code
<script type="text/javascript">
    function onComplete(e) {
        var detailWindow = $("#Details").data("tWindow");
        var eticket = e.response.eTicket;
        var version = e.response.version;
        var detail = {ID: eticket, Version: version};
            detailWindow.ajaxRequest( "/ETicket/Details", { model: detail });
            detailWindow.center().open();
    }
</script>

My Model:
    Public Class ETicketDetailViewModel
 
#Region "Fields"
 
        Private _eticket As ETicket
        Private _version As String
        Private _id As Integer
#End Region 'Fields
 
#Region "Constructors"
 
        Public Sub New(ByVal eticket As ETicket)
            Me.ETicket = eticket
        End Sub
 
#End Region 'Constructors
 
#Region "Properties"
 
        Public Property ETicket() As ETicket
            Get
                Return _eticket
            End Get
            Set(ByVal value As ETicket)
                _eticket = value
            End Set
        End Property
 
        Public Property Version() As String
            Get
                Return _version
            End Get
            Set(ByVal value As String)
                _version = value
            End Set
        End Property
 
        Public Property ID() As Integer
            Get
                Return _id
            End Get
            Set(ByVal value As Integer)
                _id = value
            End Set
        End Property
 
#End Region 'Properties
 
    End Class

I hope I have given enough details so that someone is able to assist me.

Thanks for any and all the Help

Patrick Jackson

Update:

OK so I got my initial problem fixed, but now I'm having an issue where no matter what I enter as the JSON parameter in the ajaxRequest, regardless if it is a string, int, or anything else.  On the Controller Method side of things the passed-in variable is empty.  I have ensured that the datatype on both sides are the same, but am still getting the error.

Here is my current Javascript and Method:
function onComplete(e) {
        var detailWindow = $("#Details").data("tWindow");
        detailWindow.ajaxRequest("/ETicket/Details", { "ID": e.response.eTicket[0].Value + e.response.eTicket[1].Value });
        detailWindow.center().open();
}

Public Function Details(ByVal ID As String) As ActionResult
      Dim model As New ETicketDetailViewModel
      Dim IDNum As Integer = CInt(ID.Substring(0, ID.Length - 1))
      Dim Version As String = ID.Substring(ID.Length - 1)
      If Version = "O" Then
          model.ETicket = EticketService.Details(IDNum)
      ElseIf Version = "V" Then
          model.ETicket = EticketService.Details(IDNum)
      End If
      Return PartialView(model)
  End Function

Please Help

Final Update:

YAA!!!  I finally got it all working.  I figured out why it wasn't going over to the Controller Method.  It turns out that the problem was my variable name.  The word ID apparently was assigned to something else in my project, and so it never assigned it in my Action Method.  I renamed the variable to IDNum, and it works like a champ.
Tags
Window
Asked by
Patrick Jackson
Top achievements
Rank 1
Share this question
or