Thanks for your time, this seems to be a solution to exactly what I want 
however when I try to implement it I get this error:
Resource interpreted as Document but transferred with MIME type 
application/json

Should this be a problem because I am including the web2py javascript also? 
It needs to be included because of these other stuff like the 
web2py_ajax_page function and others.




quinta-feira, 29 de Junho de 2017 às 12:53:33 UTC+1, Anthony escreveu:
>
> Are you using this notification plugin for all flash messages on your 
> site? If so, why not just incorporate it into the layout and use 
> response.flash (and session.flash) as usual? In the layout, you could have 
> something like:
>
> <script>
> $.notific8('{{=response.flash}}');
> </script>
>
> If you need to pass in options as well, you could make response.flash a 
> dictionary holding both the message and the options and convert the options 
> part to JSON in the layout:
>
> In controller:
>
>     response.flash = dict(message='There is an error.', options=dict(
> heading='Error'))
>
> In layout:
>
> <script>
> var w2p_flash = {{=response.json(response.flash) if response.flash else 
> 'null'}};
> if (w2p_flash) {
>     $.notific8(w2p_flash.message, w2p_flash.options);
> }
> </script>
>
> Anthony
>
> On Thursday, June 29, 2017 at 6:49:20 AM UTC-4, Filipe Reis wrote:
>>
>> Hello, I was wondering if someone could help me in figuring this out.
>>
>> I have a view that when the user click on a button opens a modal with a 
>> insertion form.
>>
>> I'm calling it by doing this way:
>> web2py_ajax_page("GET", url, "", target);
>>
>> url - being the url like /house/create
>> target - being the div where the form will appear
>>
>> on the form validation I'm trying to use this plugin: 
>> https://github.com/willsteinmetz/notific8 to show flash messages as it 
>> is in javascript when the form is an error I am able to do this:
>> response.js = "$.notific8('Please fill all necessary fields.', {heading: 
>> 'Error'});" 
>>
>> All works ok in here..
>>
>> but if I try the same when the form is success does not work because I do 
>> a redirect after which resets the page and there is no flash message no 
>> more... 
>>
>> I know that session.flash migh work for this cases, but I'm not able to 
>> understand how to make them work together in this case since this 
>> notification plugin works using javascript.
>>
>> Any ideas?
>>
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to