I'm trying to create a custom tree in 4.5 and have worked out the following from reflector, but when i use this the apostrophies are getting encoded to \u0027. My JsFunctionName for the action is as follows:
public string JsFunctionName { get { return "UmbClientMgr.openModalWindow('theoutfield/doctypeextensions/dialogs/ChangeMasterDocType.aspx?id='+ UmbClientMgr.mainTree().getActionNode().nodeId +'&rnd='+ this._utils.generateRandom(), uiKeys['actions_change_master_doc_type'], true, 500, 480);"; } }
It doesn't throw an error, but obviously it doesn't know what my action method is. Only way I can think to solve it at the moment, is go with just a simple method call, and set the JsSource to point to a js file with the method defined in it?
In the source code there is the follow comment for JsSource:
"A path to a supporting JavaScript file for the IAction. A script tag will be rendered out with the reference to the JavaScript file.", so yeah probably want to change that to a local js-file of your own. But remember that JsSource doesn't work in 4.0.x ;)
You can include your javascript function in the JsSource property. This is inline javascript instead of referencing an external file, must be a bug in the documentation.... Downside is that you can't use it in 4.0 because of a bug in 4.0 :-(. In the JsFunctionName prroperty you can include javascript that calls your Javascript function, so no need for an external file. In the coming week I will create a blogpost how I solved the compatibility issue between 4.0 and 4.5.
I had some issues when testing IAction functionality, I think related to caching. I solved it by logging out and do an iis reset before testing the feature.
Is this even valid markup? Shouldn't the method be defined between the script tags? This to me suggests that the JsSource property should only really be used to link to an external file. Do you get different results Richard?
Pretty sure its not valid, so a bit suprised it worked. I'm going to reference an external js file in my update of the Analytics package, and use the JsFunctionName from the Action with a combination of the compatibility check, which Ricard mentioned above. This'll work fine and I won't add inline JS to JsSource - thats just nasty :-D
First off I wasn't sure if the content of JsSource would be added as inline JS or a reference to a file, but now I'm sure. I would recommend you also reference a js file. But if you find another solution please let me know ;)
Dunno about the Markup. If it is invalid it's something that should be fixed into the core ClientManager. I will write a blogpost about the compatibilty issues today or tomorrow.
UmbClientMgr.openModalWindow encoding apostrophies
Hey Guys,
I'm trying to create a custom tree in 4.5 and have worked out the following from reflector, but when i use this the apostrophies are getting encoded to \u0027. My JsFunctionName for the action is as follows:
Anyone know why this is?
Cheers
Matt
Hi Matt,
\u0027 is the unicode character for an apostrophe (or more specifically a single quote).
I'd try escaping it along the lines of:
That may work or you may need something cleverer :-)
j
Yea, I tried that, but that did't work either
Matt
Hi Matt,
Have you tried this:
I cut off some of the parameters, but my suggestion is just to format it as shown. If you look in the source of 4.5 all actions looks like:
I take it that it is an action that you are trying to create right?
- Morten
It doesn't throw an error, but obviously it doesn't know what my action method is. Only way I can think to solve it at the moment, is go with just a simple method call, and set the JsSource to point to a js file with the method defined in it?
Matt
Thought I might have found something then, but nope. Just tried:
but it stills returns a string with an apostrophe which gets converted to \u0027
Matt
Ok, this works, but it seems a bit hacky:
If this is the solution, this could be made cleaner if RegisterClientScript on ClientTools.Scripts was made public.
Matt
I think what you should do is simply add your javascript function to the JsSource and simply keep the function call in the JsFunctionName.
As I recall this is something Shannon made possible during the retreat, because the JsFunctionName expects a jQuery function call.
In the source code there is the follow comment for JsSource:
"A path to a supporting JavaScript file for the IAction. A script tag will be rendered out with the reference to the JavaScript file.", so yeah probably want to change that to a local js-file of your own. But remember that JsSource doesn't work in 4.0.x ;)
- Morten
Yea, that was my first solution here http://our.umbraco.org/forum/developers/extending-umbraco/10131-UmbClientMgropenModalWindow-encoding-apostrophies?p=0#comment36908 but I was hoping to avoid needing a seperate script file, but yea, it's looking like it's unavoidable now.
Thanks for looking into this aswell, it was driving me insane.
Matt
Hi Matt,
You can include your javascript function in the JsSource property. This is inline javascript instead of referencing an external file, must be a bug in the documentation.... Downside is that you can't use it in 4.0 because of a bug in 4.0 :-(. In the JsFunctionName prroperty you can include javascript that calls your Javascript function, so no need for an external file. In the coming week I will create a blogpost how I solved the compatibility issue between 4.0 and 4.5.
I had some issues when testing IAction functionality, I think related to caching. I solved it by logging out and do an iis reset before testing the feature.
Cheers,
Richard
Ok, so just tried Morten and Richards suggestion, and yes it does work, but the output is:
Is this even valid markup? Shouldn't the method be defined between the script tags? This to me suggests that the JsSource property should only really be used to link to an external file. Do you get different results Richard?
Matt
Pretty sure its not valid, so a bit suprised it worked. I'm going to reference an external js file in my update of the Analytics package, and use the JsFunctionName from the Action with a combination of the compatibility check, which Ricard mentioned above. This'll work fine and I won't add inline JS to JsSource - thats just nasty :-D
First off I wasn't sure if the content of JsSource would be added as inline JS or a reference to a file, but now I'm sure. I would recommend you also reference a js file. But if you find another solution please let me know ;)
- Morten
Yea, thats pretty much what I'm going with (again, would prefer not to have to have a js include for every action, but seems the only way right now).
Now I just need to get my custom doc type tree to work =)
Matt
Rich, if you could post a link here to your compatability check blog post once its up, that would be cool.
Cheers
Matt
Dunno about the Markup. If it is invalid it's something that should be fixed into the core ClientManager. I will write a blogpost about the compatibilty issues today or tomorrow.
Cheers,
Richard
is working on a reply...