It works but later I realized that it was not practical because I the logic spread between the controller, with the form generation, and vue.js directives, then the html view where I had more vue.js directives and components, and the main js vue controller.
As I didn't want to renounce to the look and feel of web2py, because I just needed a very dynamic function made in vue, and the rest of the application could be made the traditional way with web2py, I resorted to generating just once the form with web2py and copying manually the resulting html code to the html view, and that way I just have to work with the html view and the JS code as usual in vue.js apps.
With regard to passing data from the controller to vue.js, you can use {{=ASSIGNJS(key1=val1, key2=val2, ...)}} in your view and you will get those keys available as global vars in JavaScript with the needed translations to JSON in case you use complex values as lists, dicts, ...
If anybody found a better way to integrate the things, please let us know.
Hope this helps.
Best regards.
Considering the number of views, this issue is quite exciting.
Here is my experience. I use RapydML and RapydScript to generate Vue-components.
I wrote brute-force parser + made some hacks of RapydML-compiler so, as exhaust I receive single js-file with embeded template as html-string.
If anyone is interested, I can describe in more detail. In gVim it looks like this:
After getting used to the helpful web2py's html helpers, writing pure html feels really verbose. With the code you showed, the view seems somewhat similar to working with html helpers, and also looks great to write the controller in python to have it translated to javascript, if you are used to python.
Thank you for sharing it.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
{{extend 'layout.html'}}
{{block header}}<center style="background-color: #999; color:white; padding:30px"> <h1>Login Screen</h1> <p> /{{=request.application}}/{{=request.controller}}/{{=request.function}} </p></center>
<div id="app"> ${message}</div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.min.js"></script><script> Vue.mixin({ delimiters: ['${', '}'] , unsafeDelimiters: ['!{', '}'], silent: false});
// Configure Vuew new Vue({ el: '#app', data: { 'message': 'Hello World' } });</script>
{{end}}
I've been using Vue for just 30 mins and web2py for not much longer. I just wanted to get something really, really simple working. All i did was added this to index.html. I am sure this is bad practice - just a first step to trying to understand how things fit together. Thanks to Mirek's tip below i found how to change the Parameters correctly.
{{extend 'layout.html'}}{{block header}}<center style="background-color: #999; color:white; padding:30px"><h1>Login Screen</h1><p>/{{=request.application}}/{{=request.controller}}/{{=request.function}}</p></center><div id="app">${message}</div><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.min.js"></script><script>Vue.mixin({ delimiters: ['${', '}'] ,unsafeDelimiters: ['!{', '}'],
silent: false,mixin: async = true
});// Configure Vuewnew Vue({el: '#app',data: {'message': 'Hello World'}});</script>{{end}}
On Wednesday, 9 August 2017 07:24:12 UTC+6:30, 黄祥 wrote:is there any simple web2py app with js framework (whatever) that have a CRUD or GRID example?want to learn to combine it, but confuse, what is web2py job (define models, provide restful api, any others ?), what is js framework job (client side response) ? how about the form handling (web2py or js job?)some of dev in here talk about vuejs, so i just look at it and learn from the example
https://vuejs.org/v2/examples/grid-component.html
but again, don't know how to connect it with web2py, any hints or example maybe.thanks and best regards,stifan
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/620507a2-0ce9-4fbc-ab65-3a4c68162dcc%40googlegroups.com.