dashborg / hibiki

Hibiki HTML
https://www.hibikihtml.com/
Mozilla Public License 2.0
468 stars 6 forks source link

Send whole object in post body #11

Closed tenuki closed 2 years ago

tenuki commented 2 years ago

Hi!

I'm trying to post an object to a remote handler, but to get it encoded I have to pass it as one value containing the whole object instead of the whole object itself. I mean:

This works: click.handler="$.ret = POST /publicaciones/id(object=$.currentInstance)". But I would need this to work: click.handler="$.ret = POST /publicaciones/id($.currentInstance)".


Other way would be to able to specify the post body from fn:json via http module, but haven't found how to do that too.

Btw, I found really useful #9 and its answer, and perhaps it would be nice to:

  1. being able to craft dynamic urls without need to use callhandler
  2. perhaps being independently to encode parameters on url as on body.. although it is not as powerful enough as callhandler is.. but that last points aren't related to this issue.

Thanks

sawka commented 2 years ago

Hi @tenuki, yes, there is a way to do this. Use @data=$.currentInstance to set the complete data object. Note that these parameters are set first, and then individual parameters can be specified to override what was put in @data

$.ret = POST /publicactions/id(@data = $.currentInstance);
$.ret = POST /publicactions/id(@data = $.currentInstnce, x = 5);
tenuki commented 2 years ago

Hey! Thanks! I missed that.. I'm using @data with callhandler.. now it really would be nice to have all in one place : to post to /publications/$.currentInstance.id(@data = $.currentInstance) for example. ( useful for people using: https://foalts.org/docs/architecture/controllers#the-controller-method-arguments ).

Thank you!!!