[Catalyst] Using Jquery UI
Autocomplete widget with Catalyst::View::JSON
Ben van Staveren
benvanstaveren at gmail.com
Mon Apr 26 07:25:02 GMT 2010
You can do that with View::JSON :) Just read the docs though, the reason
it didn't work is that you put your data in
$c->stash->{json} = [ ... ]
And View::JSON will attempt to turn your entire stash into JSON data :)
And it does that bit correctly, but the thing you end up with is
{
json: [ ... ]
}
And autocomplete doesn't like that. So, either do:
$c->stash([ ... ])
Or set the expose_stash setting. Whatever is set in there, is the only
thing that View::JSON will attempt to serialise.
Personally I prefer expose_stash => 'json', so that anything under
$c->stash->{json} is serialised, but up to you :)
Hetényi Csaba wrote:
> Dear Ben van Staveren
>
> Thank You, now it is working, but in this case, i don't know
> why to use Catalyst::View::JSON, it is just a text formatting.
> Later I'd like to use DBIx datasource to feed autocomplete plugin,
> in this case i must manually build a special JSON formatted string.
> Is there exist a better way?
>
> Thank You!
>
>
> Ben van Staveren írta:
>> Looks like you need to set
>>
>> expose_stash => 'json'
>>
>> in your config.
>>
>
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
--
Ben van Staveren
phone: +62 81 70777529
email: benvanstaveren at gmail.com
More information about the Catalyst
mailing list