[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-30 Thread DenesL
I meant the web2py online book http://web2py.com/book or is this the same somehow?. On Tuesday, October 29, 2013 8:03:36 PM UTC-4, Niphlod wrote: free and available here github.com/mdipierro/web2py-book On Tuesday, October 29, 2013 10:13:28 PM UTC+1, DenesL wrote: Is the book open

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-29 Thread DenesL
@Niphlod the workaround is required because web2py creates data-options={mode:calbox} which ends up like this in the INPUT element source code in the generated page mode:calbox}= data-options={ All works fine if the output from web2py is enclosed in single quotes instead, as in

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-29 Thread Niphlod
I generated that simply with data=dict(options='{mode : calbox}') On Tuesday, October 29, 2013 11:52:55 AM UTC+1, DenesL wrote: @Niphlod the workaround is required because web2py creates data-options={mode:calbox} which ends up like this in the INPUT element source code in the generated

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-29 Thread Anthony
@Anthony from module import * def f(): header = ... content = GRID(... ( # CALBOX used to create one of the columns footer = return {'page':PAGE(header, content, footer)} I guess it's hard to say without knowing what those other functions do, but I don't think web2py is

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-29 Thread Anthony
Anyway, it might not be a bad idea to allow the option to use single quotes around an HTML attribute, though not sure of the best way to achieve that. Maybe use a double underscore to identify such attributes: INPUT(..., **{'__data-options': XML('{mode:calbox}')}) or add a json argument to

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-29 Thread DenesL
The other functions are pretty ordinary, there are just wrappers of the standard helpers. Most of them return DIV with some added attributes for jQuery Mobile. On Tuesday, October 29, 2013 8:36:19 AM UTC-4, Anthony wrote: @Anthony from module import * def f(): header = ... content

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-29 Thread DenesL
True, thanks. That generates HTML entities in the output which work fine as you pointed out before: data-options='{quot;modequot;:quot;calboxquot;}' Probably it was that presentation that got me started on using XML to get rid of them. On that note two things spring to mind: 1) Add an entry

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-29 Thread Niphlod
but why since data=dict(options='{mode : calbox}') works fine ? Il giorno martedì 29 ottobre 2013 13:49:12 UTC+1, Anthony ha scritto: Anyway, it might not be a bad idea to allow the option to use single quotes around an HTML attribute, though not sure of the best way to achieve that. Maybe

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-29 Thread Anthony
Yeah, I suppose it's not necessary as long as quot; within the string never causes any problems. Anthony On Tuesday, October 29, 2013 11:47:10 AM UTC-4, Niphlod wrote: but why since data=dict(options='{mode : calbox}') works fine ? Il giorno martedì 29 ottobre 2013 13:49:12 UTC+1, Anthony

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-29 Thread DenesL
This dead horse could take one last beating, couldn't it?. On Tuesday, October 29, 2013 11:47:10 AM UTC-4, Niphlod wrote: but why since data=dict(options='{mode : calbox}') works fine ? Il giorno martedì 29 ottobre 2013 13:49:12 UTC+1, Anthony ha scritto: Anyway, it might not be a bad

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-29 Thread Niphlod
seems that any major js framework accessing data-* do the escaping (as they should) so it's really not a problem. On Tuesday, October 29, 2013 5:01:22 PM UTC+1, Anthony wrote: Yeah, I suppose it's not necessary as long as quot; within the string never causes any problems. Anthony On

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-29 Thread DenesL
Is the book open to editors?. I still would like to add an example about this in there. -- 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

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-29 Thread Niphlod
free and available here github.com/mdipierro/web2py-book On Tuesday, October 29, 2013 10:13:28 PM UTC+1, DenesL wrote: Is the book open to editors?. I still would like to add an example about this in there. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-28 Thread DenesL
Thanks Anthony, it sounds like a good idea but the browser ends up receiving: data-options={quot;modequot;:quot;calboxquot;, quot;useNewStylequot;:true} We need to make this easier (let alone work), the newer mobile add-ons/plug-ins are using the data attributes a lot. If anyone else wants

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-28 Thread Anthony
On Monday, October 28, 2013 10:46:30 AM UTC-4, DenesL wrote: Thanks Anthony, it sounds like a good idea but the browser ends up receiving: data-options={quot;modequot;:quot;calboxquot;, quot;useNewStylequot;:true} When I try it, web2py returns the following to the browser: input

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-28 Thread DenesL
Check the source of the returned page, is it still good?. The code is: def CALBOX(*args, **vars): vars['_type']='text' vars['_data-role']='datebox' vars['data']={'options':XML('{mode:calbox, useNewStyle:true}')} x = INPUT(*args, **vars) return XML(x.xml().replace('{', '{).replace('}',

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-28 Thread Niphlod
BTW, the quoted representation **should** be valid nonetheless. What plugins do is extracting whatever is in the data and evaluating to a js object, so it shouldn't really matter beween data-something='{a: b}' and data-something=thequotedrepr_of_{a:b} unless the plugin is so strict (and

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-28 Thread DenesL
Thanks Niphlod, that is true. The problem was in one of the js files from dev.jtsage.com (or with the one I had downloaded). It works fine with the latest from their cdn http://dev.jtsage.com/cdn/datebox/latest/ *Still, having to add Anthony's trick seems very un-web2py-ish*

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-28 Thread Niphlod
@DenesL...uhm...what I was saying is that a plugin **should** expect anything in a data-* to be escaped. This means that from a plugin standpoint, input data-options={quot;modequot;:quot;calboxquot;} type=text id= test1 / should be treated exactly as input data-options='{mode:calbox}'

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-28 Thread Anthony
CALBOX(_name='tsdate', _id='tsdate') Where exactly does the above line go? When I try you exact code, I do not get any escaping of the quotes (checked the source returned to the browser and even tried using gluon.tools.fetch from the shell). Anthony -- Resources: - http://web2py.com -

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-26 Thread Niphlod
what are you expecting to see in the raw generated input ? On Friday, October 25, 2013 11:57:48 PM UTC+2, DenesL wrote: using web2py 2.5.1 source on windows Having trouble creating an INPUT with a non-trivial data attribute. Did try the following:

[web2py] Re: having trouble with data-xxx when they are not a simple option

2013-10-26 Thread Anthony
Attributes are always put in double quotes: https://github.com/web2py/web2py/blob/master/gluon/html.py#L907. I suppose you could manually replace the double quotes after serializing: input = INPUT(..., data={'options': XML('{mode:calbox}')}) XML(input.xml().replace('{', '{).replace('}', }'))