You can probably do something similar with v1.4 using the buildRequest
function in hjq.js. There are comments explaining its usage and you
can look through hjq.js for examples. If you start down this path and
want some help, I'll be glad to help.
However, what I would recommend instead would be to add a hidden form
to your HTML
<div style="display: none;">
<form update="myresponse" action="&some_path" success="my_function">
<inputs that can be manipulated/>
<div part="myresponse"><% #code that calculates the response to
the ajax %></div>
<submit id="#mysubmit"/>
</form>
</div>
Then you can manipulate this form via jQuery DOM manipulation to
change the action and manipulate inputs, and then use jQuery to click
on the submit button. Your success function can then pull the answer
out of myresponse and put it where you want it. Alternatively you
can use a larger part and then you won't have to move the response.
Hopefully this also means you don't have to call init() again,
depending on how well the items you move deal with being moved.
This method should work with both 1.3 & 1.4 and future versions is
easier to debug because you can unhide it and play with it manually.
The above approach is probably your best option if you want to return
HTML in your Ajax. If your Ajax returns something other than HTML,
you're probably best off just using jQuery.ajax and rolling your own
controller code.
Bryan
On Sat, Jul 7, 2012 at 8:55 AM, devcurmudgeon <[email protected]> wrote:
> Thanks Bryan.
>
> Sorry to go around again, but assuming we have the dialog plumbing working,
> what would be the recommended Hobo 1.4 way to retrieve the data from the
> server-side db?
>
> In 1.3 we've used Hobo.ajaxRequest as follows, but it's always seemed like
> hard work to me, and CHANGES-1.4.txt note suggests you've dropped this for
> 1.4 anyway
>
> Hobo.ajaxRequest( "/items/" + item_id + "/ajax_item",
> [],
> { params: { item_id: item_id },
> action: 'ajax_item',
> controller: 'items',
> method: 'get',
> message: "Please wait",
>
> onSuccess: function(transport) {
> jQuery("#edit-item-dialog").empty();
>
> jQuery("#edit-item-dialog").append(transport.responseText);
>
>
> jQuery("#edit-item-dialog").find('.hjq-annotated').each(function() {
> var annotations = hjq.getAnnotations.call(this);
> if (annotations.init) {
>
> hjq.util.createFunction(annotations.init).call(this, annotations);
> };
> });
>
> hjq.dialog_opener.click(this,
> jQuery('#item-dialog-s' + item_id));
> },
>
> onFailure: function(transport) {
> jQuery("#edit-item-dialog").empty();
> }
> } );
>
> }
>
> On Wednesday, July 4, 2012 5:18:29 PM UTC+1, Bryan Larsen wrote:
>>
>> Here's the promised example:
>>
>> <dialog-box id="mydialog">
>> <div id="message"/>
>> </dialog-box>
>>
>> <dialog-open-button dialog="#mydialog"
>> onclick="$('#message').text('hello')"/>
>>
>> Replace .text('hello') with whatever DOM manipulation is required to
>> get the desired results.
>>
>> Bryan
>
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/hobousers/-/J07D5x7fDj0J.
>
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/hobousers?hl=en.
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en.