I get an error while adding a partial form to my current form (kind of parent/child).
The partial form is loaded with ajax and there can be none to several partial forms/childs.
I got it working that every partial form gets an ID and I can save etc, but everytime I click on the 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 drives me crazy :) I'm new to javascript/ajax, might be an obvious error :(
Edit: Here is the function AddAddress 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);
}
The 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 meanwhile I tried some other stuff, when I use the debug.js I get
Sys.ArgumentUndefinedException: Value cannot be undefined. Parameter name: method
I changed the OnSuccess to
OnSuccess = "function() { ListApi.ResetAddLink(event, '" + AdressListIndexName + "'); }"
Now I get a simple "Object required" :(