Anonymouse object DONT work if defined inside an action
M
Mackey Kinard
started a topic
almost 3 years ago
the following code snippet show me trying to do an Alert Message Box from inside
the callback of and Config Message Box:
Webix.confirm(new {
title = "Customtitle",
ok = "Yes",
cancel = "No",
type = "confirm-error",
text = "Testconfirm",
callback = newAction<object>(result => { var tester = new { title = "TESTTITLE", text = "TESTALERTMESSAGE" }; Webix.alert(tester);
})
the line:
var tester = new { title = "TESTTITLE", text = "TESTALERTMESSAGE" };
gives a error: TypeError: Cannot read property 'ctor' of undefined
now if i either MOVE the var tester = new { title = "TESTTITLE", text = "TESTALERTMESSAGE" };
to OUTSIDE of the Action<> BEFORE the confirm it works Fine.
ALSO if i wrap in a Js.@object() then it works INSIDE the action:
Js.@object(var tester = new { title = "TESTTITLE", text = "TESTALERTMESSAGE" });
BUT I DONT WANNA HAVE TO PREFIX ALL MY ANONYMOUSE OBJECTS WITH
Js.@object()
ALSO NOTE: It only gives error if you do a 'new {}' INSIDE AN Action (So far... that is all i encountered the problem)
1 Comment
Daniel Zeitlin
said
almost 3 years ago
We fixed this issue iv the coming v1.1, the problem was with nested anonymous classes.
Mackey Kinard
the following code snippet show me trying to do an Alert Message Box from inside
the callback of and Config Message Box:
Webix.confirm(new {
title = "Custom title",
ok = "Yes",
cancel = "No",
type = "confirm-error",
text = "Test confirm",
callback = new Action<object>(result => {
var tester = new { title = "TEST TITLE", text = "TEST ALERT MESSAGE" };
Webix.alert(tester);
})
the line:
var tester = new { title = "TEST TITLE", text = "TEST ALERT MESSAGE" };
gives a error: TypeError: Cannot read property 'ctor' of undefined
now if i either MOVE the var tester = new { title = "TEST TITLE", text = "TEST ALERT MESSAGE" };
to OUTSIDE of the Action<> BEFORE the confirm it works Fine.
ALSO if i wrap in a Js.@object() then it works INSIDE the action:
Js.@object(var tester = new { title = "TEST TITLE", text = "TEST ALERT MESSAGE" });
BUT I DONT WANNA HAVE TO PREFIX ALL MY ANONYMOUSE OBJECTS WITH
Js.@object()
ALSO NOTE: It only gives error if you do a 'new {}' INSIDE AN Action (So far... that is all i encountered the problem)