ilyavf
July 31, 2016, 12:22am
1
Update : here the bug is reproduced .
I have the following template (grabbed from can.autorender docs ):
<body>
<script id="demo" type='text/stache' can-autorender>
Autorender: message = {{message}}!
</script>
<script src='node_modules/steal/steal.js'
main='can/view/autorender/'>
</script>
</body>
The fragment created for the table is rendered right after the script tag. Is its viewModel supposed to be accessible (attached) via the script tag?
When in console I am trying:
$('#demo').viewModel().attr('message','test')
the message is not getting updated.
Note: this happens only for StealJS setup.
In your jsbin you have:
$('demo').viewModel('message','Hi')
Where it should probably be:
$('#demo').viewModel('message','Hi')
It also looks as though one can set individual attributes as follows:
$('#demo').viewModel().attr('message','Hi')
It also appears as though the following works as it would replace the entire model:
$('#demo').viewModel({ message: 'Hi'})
Although, one would probably want to use a real model such as a can.Map
or other structure.
The console also seems to work. Did you perhaps leave out the #
there too (although you have it in the quetion).
ilyavf
August 1, 2016, 3:31am
3
Hi Eben, thank you for the corrections of my mistakes in JSBin. So, in this JSBin I cannot reproduce my problem that I have with StealJS setup. I should probably try to publish it somewhere.
ilyavf
August 1, 2016, 9:52pm
4
Here the bug is reproduced with StealJS setup .
Here in JSBin without StealJS its working well
The $('#demo').viewModel()
has the updated message
property, but the template is not getting updated.
Also, _cid
in the 1st case is .map8
, in JSBin its .map3
.