0

How to pass data from view model to client side script?

asked 2012-10-24 17:34:21 +0800

calavera gravatar image calavera
21

Hi,

we have a client side script which is parametrized by data in the view model. I'm sure it must be a very common case, but I can't figure out how to do that. I would like to try to use @load annotation to somehow fill some variable in my script, but the longer I'm thinking about it the more I'm afraid it's not possible. Do someone have some experience with that?

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2012-10-25 02:44:05 +0800

MontyPan gravatar image MontyPan
435 3
http://xitop.blogspot.com...

Hi Calavera,

Sorry, I can't understand your question. Can you provide pseudo code?

Regards,
Monty Pan

link publish delete flag offensive edit

answered 2012-10-25 12:55:32 +0800

calavera gravatar image calavera
21

I have a solution for this already. The use case is that we have custom javascript-only implementation of calendar and we need to set disabled days on this calendar. Disabled days varies through different pages and is even dependent on data that user inputs. I used this construction:

<script>
function someCallback(dynamicData) {
alert(dynamicData);
}
</script>

<script content="@load(vm.selectedAccount) @converter(jsonDataConverter)">
<custom-attributes callbackName="someCallback"/>
</script>

And all the magic is done in the converter.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-10-24 17:34:21 +0800

Seen: 153 times

Last updated: Oct 25 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More