Hijax not detecting white spaces!

0 views
Skip to first unread message

Jrad

unread,
Jul 18, 2010, 7:25:29 AM7/18/10
to jquery-claypool
Dear chris,
I observed that hijax is not matching urls with spaces. I even did
encode them with native js function, but again no success! Our rules
is as below:
"hijax:a" : [{
id:"#lbd-hash-routes",
active:true,
filter:"[href*=#lbd]",
hijaxMap: [

{urls:"lbd/|:controller|/|:action|/|:id|/|:rev|/|:param3|$",
controller:"#lbdController"},
{urls:"lbd/|:controller|/|:action|/|:id|/|:rev|$",
controller:"#lbdController"},
{urls:"lbd/|:controller|/|:action|/|:id|$",
controller:"#lbdController"},
{urls:"lbd/|:controller|/|:action|$",
controller:"#lbdController"}
]
}],
example link href:"#lbd/cont/action/id/rev/my file name 1"
My second question about routes is that if I can reduce my hijaxMap?
I've used 4 rules to capture links with 3 params, 2 params, 1 param
and without parameter! Is there any way I can write a regex rule to
capture all scenarios with any number of parameters?

chris thatcher

unread,
Jul 18, 2010, 1:59:22 PM7/18/10
to jquery-...@googlegroups.com
Great question, and the answer is yes.  Here is the rundown on regular expressions with routes:

|:word|
a short hand to allow easy construction of routes which use 'words' this includes a-z, A-Z, 0-9, _ and -

<:expression(regexp):>
Allows full control of the expression used in the capture. for example

<:rev([\s\w]*):>
would be enough to capture your example i think.

There might be room for improvement but in general it's worked well, though admittedly I tend to use shorter urls.  In some cases it may me easier to try to cram less into the url and allow the creation of more routers which use filters to seperate, for example the controller parameter in your example.  This may not be possible though based on your requirements.

One thing I've added locally which stills needs a little work is normalization for the form and link routers so that form values are included in the event.param() map and for the link router event.param() will include the url ? parameters.  for example

foo/bar/?abc=123&def=456

so if you had a link router like foo/|:id|

you would get an event.params() which returns
{
    id: 'bar',
    abc: '123',
    def: '456'  
}

I'll get that pushed out to trunk tonight so you can play with it as well.  If you have some ideas of how you might like to simply your particular issue, let me know and we can see if  we can find a good solution in that direction.

Thatcher


--
You received this message because you are subscribed to the Google Groups "jquery-claypool" group.
To post to this group, send email to jquery-...@googlegroups.com.
To unsubscribe from this group, send email to jquery-claypo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jquery-claypool?hl=en.




--
Christopher Thatcher

Jrad

unread,
Jul 19, 2010, 8:20:56 AM7/19/10
to jquery-claypool
Thank you for your information.
Would you mind re-writing my hijax:a rule above with the information
you provided?
Should i use <:rev([\s\w]*):> Or |:rev([\s\w]*):| ???

On Jul 18, 9:59 pm, chris thatcher <thatcher.christop...@gmail.com>
wrote:
> > jquery-claypo...@googlegroups.com<jquery-claypool%2Bunsu...@googlegroups.com>
> > .

chris thatcher

unread,
Jul 19, 2010, 10:35:32 AM7/19/10
to jquery-...@googlegroups.com
<:rev([\s\w]*):> would probably work though I havent tested the particular case.

One caveat is that currently claypool requires a given route to use all |:path|/|:to|/|:something| or <:path(\w+):>/<:to(\d+):>/<:something([a-z-_]):> for example.

What I would actually recommend is trying the latest form trunk.  I added the normalization to link and form routers so if you had urls like:

ldb/foo/save/1234?rev=awe aweg r&param3=wegpa

you could use the basic three basic word routes which are very readable, while still allowing the extra params so your app can grow without always having all params in the path of the url:

|:controller|
|:controller|\|:action|
|:controller|\|:action|\|:id|

would still get
event.param('rev') returns 'awe aweg r'

Thatcher

To unsubscribe from this group, send email to jquery-claypo...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/jquery-claypool?hl=en.




--
Christopher Thatcher
Reply all
Reply to author
Forward
0 new messages