I created a custom action for my custom tree. Now I want the modalWindow to appear after the action is clicked. In the modalWindow I want to get the id of the node just clicked. How can I do this. I've got the following in my action:
public string JsFunctionName
{
get
{
return "ShowCreateCategory()";
}
}
/// <summary>
/// This is a path to a JavaScript file that contains the custom JavaScript to call.
/// </summary>
public string JsSource
{
get
{
//Assign a function.
//return "function ShowCreateCategory(){ parent.right.document.location.href = '" + VirtualPathUtility.ToAbsolute("/umbraco/sections/articles/CreateCategory.aspx") + "?id=' + UmbClientMgr.mainTree().getActionNode().nodeId ; }";
return "function ShowCreateCategory(){" + ClientTools.Scripts.OpenModalWindow("/umbraco/sections/articles/CreateCategory.aspx", "test", 750, 550) + "}";
}
}
The first line in comment doens't pop-up but goes directly to a page. That works. The second line opens the pop-up and that also works, but without the id passing. I tried the following to pass the id:
That doens't work because it's a javascript function (as you can see in the commentend line) and this is c#. Somehow need to call that javascript function while passing it into the ClientTools.Scripts.OpenModalWindow method. You're probably right and it's a syntax error, but I can't find it.
I opened the javascript with '+ but because there comes more javascript after my code I should also end it with +'. It was a syntax error after all :).
How to pass id in custom action?
Hello,
I created a custom action for my custom tree. Now I want the modalWindow to appear after the action is clicked. In the modalWindow I want to get the id of the node just clicked. How can I do this. I've got the following in my action:
The first line in comment doens't pop-up but goes directly to a page. That works. The second line opens the pop-up and that also works, but without the id passing. I tried the following to pass the id:
If I know click on my action nothing happens. I'm doing something wrong but I don't know what. Hope someone can help me :).
Thanks.
Jeroen
Seems your
UmbClientMgr.mainTree().getActionNode().nodeId;
is part of the string, should be " + UmbClientMgr.mainTree().getActionNode().nodeId + "
Hope this helps.
Regards,
/Dirk
That doens't work because it's a javascript function (as you can see in the commentend line) and this is c#. Somehow need to call that javascript function while passing it into the ClientTools.Scripts.OpenModalWindow method. You're probably right and it's a syntax error, but I can't find it.
Jeroen
Here's a sample I use on a site and works perfectly:
So yes, yours will be seen as a string rather than a c# function...
It's just wrong use of ' and "
Have to replace the first " by a single ' and make sure you're also closing the string before joining with the UmbClientMgr.mainTree()...
Cheers,
/Dirk
Thank you Dirk I got it solved. Because of your sample I saw what I was doing wrong. Here is the line that works:
I opened the javascript with '+ but because there comes more javascript after my code I should also end it with +'. It was a syntax error after all :).
Jeroen
is working on a reply...