Dynamic Forms, Microsoft JScript Runtime Error: "b" is null or not an object

I am getting an error while adding a partial form to my current form (parent / child view).

The partial form is loaded with ajax and cannot be any partial / childs form.

I got it that every partial form gets an ID and I can save and so on, but every time I click ActionLink I get:

Microsoft JScript runtime error: 'b' is null or not an object

      

My ActionLink:

      <%=Ajax.ActionLink("Add Address", "AddAddress", new 
        {
            Prefix = ViewData["Prefix"],
            ListDivName = AdressListDivName,
            ListIndexName = AdressListIndexName,
            ListIndex = AdressListIndex
        }, 
        new AjaxOptions 
        {
            UpdateTargetId = AdressListDivName,
            OnSuccess = "ListApi.ResetAddLink(event,'" + AdressListIndexName + "')",
            InsertionMode = InsertionMode.InsertAfter 
        })%>

      

I googled around and found others with the same error but different links

This error is driving me crazy :) I am new to javascript / ajax, there might be an obvious error :(

Edit: here is the AddAddress function in the controller:

public ActionResult AddAddress(string Prefix, string ListDivName, string       ListIndexName, int ListIndex, string lang)
    {
        MyAdress aa = new MyAdress { };

        ViewData["PageLang"] = lang;
        ViewData["Prefix"] = Prefix;
        ViewData["ListDivName"] = ListDivName;
        ViewData["ListIndexName"] = ListIndexName;
        ViewData["ListIndex"] = ListIndex;

        return View("_MyAdresseListItem", aa);
    }

      

Javascript function:

ListApi.ResetAddLink = function(evt, ListIndexName) {
evt = evt || window.event;
var target = evt.target || evt.srcElement;

var Index = parseInt(document.getElementById(ListIndexName).value);
var Pre = target.href.substring(0, target.href.lastIndexOf("=") + 1);

Index = Index + 1;
document.getElementById(ListIndexName).value = Index;

target.href = Pre + Index;
}

      

Update

In the meantime I tried some other things, when I use debug.js I get

Sys.ArgumentUndefinedException: Value cannot be undefined. Parameter name: method

      

I changed OnSuccess to

OnSuccess = "function() { ListApi.ResetAddLink(event, '" + AdressListIndexName + "'); }"

      

Now I am getting a simple "Object required" :(

+2


source to share


1 answer


The problem was the event was not passed correctly in the OnSuccess function ... so I decided to pass the information in the functions rather than pass the event and grab the information from there ...



+2


source







All Articles