Hobo without prototype.js, alpha release

122 views
Skip to first unread message

Bryan Larsen

unread,
Dec 7, 2011, 4:21:28 PM12/7/11
to Hobo Users
I'm proud to announce that you can now run Hobo without prototype.js.
Since this involved rewriting a large part of our javascript, a good
number of enhancements came along for the ride.

To view the change list and installation instructions, see the README
on the no-prototype branch of hobo-jquery:

https://github.com/bryanlarsen/hobo-jquery/tree/no-prototype

The code structure is currently a mess. The javascript is nicely
organized into many small files. This is suboptimal for web apps,
but the Rails 3.1 asset pipeline should take care of this nicely for
us. (the no-prototype branch currently uses Rails 3.0, but it will
be Rails 3.1 when it merges into master).

On the other hand, hobo-jquery.rb and hobo-jquery.dryml are giant
files containing everything except the kitchen sink. That's because
they'll probably be merged into Hobo 1.4 so any effort spent
organizing them would be wasted.

This impacts you because you'll have to look into hobo-jquery.dryml
for tag documentation. OTOH this is an alpha release with both tests
and documentation.

There are a couple of little-used tags that have not yet been
converted (sortable-input-many, name-many). It's only been tested
against agility, but agility does try to touch on pretty much every
aspect of Hobo.

As this is an alpha release, the API is subject to change, although
such changes will probably be trivial. In fact, I want you to read
through the README and double check my choices for tag, attribute and
parameter names, noting places where my choices are suboptimal.

cheers,
Bryan

Owen Dall

unread,
Dec 7, 2011, 4:29:09 PM12/7/11
to hobo...@googlegroups.com
Great work, Byran!
 
-Owen


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




--
-Owen
 
Owen Dall, Chief Systems Architect
Barquin International

Bryan Larsen

unread,
Dec 7, 2011, 4:35:32 PM12/7/11
to hobo...@googlegroups.com
Thank you, Owen, for letting me delay Barquin's Portal 2.0 project to
get this out the door.

cheers,
Bryan

Owen Dall

unread,
Dec 7, 2011, 4:42:49 PM12/7/11
to hobo...@googlegroups.com
This is great stuff. Hope the community will appreciate it!
 
-Owen

Ignacio Huerta

unread,
Dec 16, 2011, 2:42:13 PM12/16/11
to hobo...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I've been terribly busy and unable to follow the latest updates, but
this is amazing Bryan.

We already use a lot of parts, hobo-jquery and Ajax uploads, so these
changes are a huge improvement for us. And the live-editor? I have to
try that one!

I'd like to suggest one small change: "hjq-datepicker" is a bit too
hard. How about calling it "datepicker" and making it the default for
date fields?

Thank you, thank you so much!

El 07/12/11 22:21, Bryan Larsen escribi�:

- --
Ignacio Huerta Arteche
http://www.ihuerta.net
Tel�fono: 0034 645 70 77 35
Email realizado con software libre
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk7rnxUACgkQBPlUJ6RHaOQ6KQCeODS4gE5JP+iFDN/Ty7h0UmLi
nzkAn1aSztKdiqzQoWb67Bwa+ZriwhE8
=YUju
-----END PGP SIGNATURE-----

Bryan Larsen

unread,
Dec 16, 2011, 2:49:47 PM12/16/11
to hobo...@googlegroups.com
The first half of your request is already done, or at least that was
the intention. All controls should have lost their 'hjq-' prefix.

To do the second half we should probably rename the default datepicker
so that people can switch back to it if they're crazy enough to prefer
the standard rails datepicker.

Bryan

On Fri, Dec 16, 2011 at 2:42 PM, Ignacio Huerta <ign...@ihuerta.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I've been terribly busy and unable to follow the latest updates, but
> this is amazing Bryan.
>
> We already use a lot of parts, hobo-jquery and Ajax uploads, so these
> changes are a huge improvement for us. And the live-editor? I have to
> try that one!
>
> I'd like to suggest one small change: "hjq-datepicker" is a bit too
> hard. How about calling it "datepicker" and making it the default for
> date fields?
>
> Thank you, thank you so much!
>

> El 07/12/11 22:21, Bryan Larsen escribió:

> Teléfono: 0034 645 70 77 35


> Email realizado con software libre
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk7rnxUACgkQBPlUJ6RHaOQ6KQCeODS4gE5JP+iFDN/Ty7h0UmLi
> nzkAn1aSztKdiqzQoWb67Bwa+ZriwhE8
> =YUju
> -----END PGP SIGNATURE-----
>

Bob Sleys

unread,
Dec 20, 2011, 12:23:34 PM12/20/11
to hobo...@googlegroups.com
I working on transitioning over to jquery.  I know its still in alpha but I figure I mind as well get started since I have a large javascript portion to the site that needs rewriting so I'll just redo it in jquery.  I have the following on the current site that works however I know is't very 'Hobo" way of doing it.  However switching over to jquery it no longer works.

In front_site.dryml I have a tag as follows that appears on all pages of the site.

<def tag="project">
  <section class="project" id="project">
    <partial name="projects/projects"/>
  </section>
</def>

Projects/_projects.dryml is.  Note this is the part that is no longer working.  It obviously has to do with the observe_field.

<unless test="&@current_organization.new_record?">
  <%= image_tag "spinner.gif", :style => "display:none;", :id => "project-spinner" %>
  <label>Orginzation:&nbsp;&nbsp;<a to="&@current_organization"><%= @current_organization.name %></a></label> &nbsp; &nbsp;
  <label><a to="&@current_organization.projects">Project</a>:&nbsp;&nbsp;</label>
  <%= select_tag "project_select",
                 options_from_collection_for_select(@current_organization.projects, "id", "list_name", @current_project.id),
                 {:include_blank => true} %>


  <%= observe_field "project_select", :url => {:action=>"select", :controller=>"projects"},
                    :method                => "GET",
                    :with                  => "'id='+value",
                    :loading               => "Element.show('project-spinner')",
                    :complete              => "Element.hide('project-spinner')" %>
</unless>

I then have an index action select in the projects controller that handles the ajax request.

In a nut shell I simply want a selection list of projects that gets submitted when the value from the selection list gets changed.  I'd love to use the default spinner instead of adding a new one but I couldn't get that to work previously.  Any help in making this work in a more Hobo and jquery way would be appreciated.

Thanks
Bob

Bryan Larsen

unread,
Dec 20, 2011, 12:36:54 PM12/20/11
to hobo...@googlegroups.com
1) have you run the jquery-rails generator? (ie, is your page loading
jquery_ujs.js?)

2) Element.show is prototype code. $("#project-spinner").show() is
the jquery equivalent.

3) $("#project_select").hjq_spinner({message: 'Loading...'}) should
open the hobo-jquery spinner and $("...").hjq_spinner('remove')
should close it.

4) This is a relatively common pattern. When your DRYML foo is up to
it, I'd love to help you package it up into a general tag to include
in hobo-jquery.

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/-/zpLsio5ME8cJ.

Bob Sleys

unread,
Dec 20, 2011, 3:08:20 PM12/20/11
to hobo...@googlegroups.com
Thank for helping out.

First yes I ran the generator and I'm getting all the jquery stuff loaded fine.

I'm now getting the following in the HTML page


<select id="project_select" name="project_select">
  <option value=""></option>
  <option value="1">100 - test</option>
  <option value="2">101 - Test 2</option>
  <option value="4">300 - test3</option>
</select>

 <script type="text/javascript">
//<![CDATA[
new Form.Element.EventObserver('project_select', function(element, value) {new Ajax.Request('/projects/select', {asynchronous:true, evalScripts:true, method:'GET', onComplete:function(request){$("#project_select").hjq_spinner("remove")}, onLoading:function(request){$("#project_select").hjq_spinner({message: "Loading..."})}, parameters:'id='+value + '&authenticity_token=' + encodeURIComponent('QZzA/Xm3YTrsO0Hz85AXbvovDJGLa1T6YKi/dQ/oybE=')})})
//]]>
</script>

It all looks good to me except the observer is never firing off.  I change the selection list and nothing happens.

Bob

Bob Sleys

unread,
Dec 21, 2011, 9:47:02 AM12/21/11
to hobo...@googlegroups.com
Think I found the problem.  The following article  http://www.alfajango.com/blog/rails-prototype-to-jquery/ talks about it down in the delayed observer part.  Basically Form.Element.EventObserver is still prototype not jquery.  The rails tag observe_field is still generating prototype code not jquery code.

Bob

Bob Sleys

unread,
Dec 21, 2011, 12:45:56 PM12/21/11
to hobo...@googlegroups.com
Well I  got this working but not very Hoboish I'm sure there is a better and easier way but for now at least this works.

<%= select_tag "project_select",
    options_from_collection_for_select(@current_organization.projects, "id", "list_name", @current_project.id),
    {:include_blank => true} %>
<script type="text/javascript">
//<![CDATA[
$('#project_select').change(function() {
$("#project_select").hjq_spinner({message: "Loading..."});
var data = 'id=' + $("#project_select option:selected").val();
$.ajax({
url : '/projects/select',
type : 'GET',
success: function(request){$("#project_select").hjq_spinner("remove")},
data : data
})
});
//]]>
</script>

Thanks again and please don't think I don't appreciate all the work done here. 

Bob

Bryan Larsen

unread,
Dec 21, 2011, 9:27:34 PM12/21/11
to hobo...@googlegroups.com
Your travails motivated me to make this sort of thing a lot easier,
because this sort of requirement is something I've run into several
times.

If you weren't on the jQuery branch I would have pointed you at
http://cookbook.hobocentral.net/recipes/33

Instead, the jquery branch now has the fancy new 'hot-input' tag.
(See my other post for details). It should be a lot simpler to use
than observe_field, and a lot more useful.

cheers,
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/-/gYzwyIx1s0gJ.

Bob Sleys

unread,
Dec 27, 2011, 1:33:02 PM12/27/11
to hobo...@googlegroups.com
Thanks Bryan,

I haven't had a chance to mess with the new tag yet but it looks great.

I minor thing I just noticed and I don't know if it has to do with the Jquery changes or other Hobo changes but in table-plus tables if you add the controls the remove button has been moved from a simple input button to putting each remove button is a form. The form tag is forcing the remove button to be on a separate line from the edit link thus placing the remove button below the edit link instead of in line with it.

Bob

Bob Sleys

unread,
Dec 27, 2011, 1:52:49 PM12/27/11
to hobo...@googlegroups.com
Oh and I just noticed the <select-one-or-new-dialog> tag doesn't work properly at all.

Bob

Bryan Larsen

unread,
Dec 27, 2011, 2:15:26 PM12/27/11
to hobo...@googlegroups.com
On Tue, Dec 27, 2011 at 1:33 PM, Bob Sleys <bsl...@gmail.com> wrote:
> I minor thing I just noticed and I don't know if it has to do with the
> Jquery changes or other Hobo changes but in table-plus tables if you add the
> controls the remove button has been moved from a simple input button to
> putting each remove button is a form. The form tag is forcing the remove
> button to be on a separate line from the edit link thus placing the remove
> button below the edit link instead of in line with it.

That was a deliberate change. The new code uses ajax forms for
everything which will allow us to remove a bunch of special case code
in Hobo.

You should be able to fix it up by adding "display:inline" to an
appropriate location in the CSS. If you figure out where the
appropriate location is before I get to it, let me know.

cheers,
Bryan

Bryan Larsen

unread,
Dec 27, 2011, 2:16:07 PM12/27/11
to hobo...@googlegroups.com
On Tue, Dec 27, 2011 at 1:52 PM, Bob Sleys <bsl...@gmail.com> wrote:
> Oh and I just noticed the <select-one-or-new-dialog> tag doesn't work
> properly at all.
>

Added to my todo list. Let me know if it gets urgent for you -- I
don't want to lose my alpha tester. :)

Bryan

Bob Sleys

unread,
Dec 27, 2011, 2:59:07 PM12/27/11
to hobo...@googlegroups.com
Ok I fixed the remove button with the following css

.table-plus table td.controls form {display: inline;}
.table-plus table td.controls form div.hidden-fields{display: inline;}

Note I had to change both the form and the hidden-fields div.

As for the select-one-or-new button don't worry I'm not going anywhere.

Bob

Bob Sleys

unread,
Jan 6, 2012, 10:08:06 AM1/6/12
to hobo...@googlegroups.com
I've pretty mush totally converted my site over to this minus the select-one-or-new tags.  A few things I've noticed.  Hoping you get to the select-one-or-new tag soon.

1. Love the new datepicker on data fields.

2. The auto sub form for has_many links needs a little work but I love the direction it's going.

2.a  First when any field on the sub form is changed the record is saved via ajax which is great except when there are validations.  Say you have 3 fields with required validations and as soon as you enter the first field on a new record the form is saved resulting in validation errors but the user never had a chance to enter the data for the other fields.  Perhaps the form needs to be submitted after the sub form looses focus and not on lose focus for each field.

2.b  If you have 2 associated records and get a validation error on the 2nd one the error messages show above all the records and the fields with errors get highlighted on all the records not just the one with errors.  I hope that makes sense if not I can attached a screen shot showing the issue.

I'm sure there are many other features that have simply worked and I never even noticed which is a great thing.

Bob

Bryan Larsen

unread,
Jan 6, 2012, 10:56:03 AM1/6/12
to hobo...@googlegroups.com
Bob, I'm glad it's working for you. I'm pleasantly surprised that
it's working so well.

If you want to give me a hand fixing the issues, the best way is to
add an example of your issues to the jquery branch of
https://github.com/Hobo/agility-gitorial/tree/jquery. I've been
adding integration tests for the new code there, so an example of your
problem will help me fix it and help me create more integration tests.
It will also give me a very clear undestanding of the problems.

thanks,
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/-/hOLLYJEwT9YJ.

Bob Sleys

unread,
Jan 6, 2012, 11:58:42 AM1/6/12
to hobo...@googlegroups.com
I'll see what I can do over the weekend.

Bob Sleys

unread,
Jan 9, 2012, 10:05:25 AM1/9/12
to hobo...@googlegroups.com
Ok I'vs cloned it and added things and abobs to demo the problem. https://github.com/bsleys/agility-gitorial

If you add a new thing (thing has_many abobs) you can add abobs to the new thing before saving the thing.  This creates new abobs in the database that arn't linked to the thing you are creating and the abobs form disappears once it is saved preventing you from adding a second abob.  If you then go ahead and save the new thing it's still isn't linked to the abob you created on the new thing form.  (note no validations are run on the abob when it is created)

If you go in an edit the thing you can add multiple abobs to it but since abob has name and name2 both being required when you fill out the name field the error messages pop up due to the missing name2.  If you go ahead and fill out name2 it gets saved to the db fine.  Now add a 2nd abob and when the error message pops up it highlight all the abob fields including for the first abob that has already been added to the db.

One last note the error messages for the abob form on the thing form only show up when the abob-view is set to <editor/> or some other variant.  IE I have the following tag in the application.dryml.  I believe if the <abobs-view:> isn't overridden the abob gets saved without any validations being run.

<extend tag="form" for="Thing">
<old-form merge>
<field-list: fields="name, abobs">
<abobs-view:>
<editor/>
</abobs-view>
</field-list:>
</old-form>
</extend>

Hope this helps.  If there is some other way I can help please let me know.  Also note I've worked around this in my app so it's not an issue for me currently just something I noticed while developing my app.

Bob

Bob Sleys

unread,
Jan 9, 2012, 6:27:23 PM1/9/12
to hobo...@googlegroups.com
Ok need the select-one-or-new tag to work so I started working on it myself.

First thing I found is the tag uses a <dialog...> tag and it appears that the tag has been renamed <dialog-box...> making that change now hides the dialog and the New button does open the dialog box which looks fine except pressing the New button to display the dialog is also submitting the form, the main form not the dialog.  I don't know how to stop that from happening.

Bob

Bob Sleys

unread,
Jan 9, 2012, 6:29:54 PM1/9/12
to hobo...@googlegroups.com
should have posted this to begin with by my copy of the tag is now this.

<def tag="select-one-or-new-dialog">
  <% dialog_id = "dialog-#{typed_id.gsub(':', '-')}" %>
  <% part_id = "select-one-#{typed_id.gsub(':', '-')}" %>
  <input part="select-one-or-new-dialog-select" id="#{part_id}"/>
  <dialog-open-button dialog="##{dialog_id}" param>
    New <%= this_field.humanize %>
  </dialog-open-button>
  <dialog-box param buttons='&[["cancel", "hjq.dialog.close"], ["ok", "hjq.dialog.submitFormletAndClose"]]' title="New #{this_field.humanize}" id="&dialog_id" >
    <formlet with="&this_type.new" update="&part_id" success="jQuery('##{part_id} select').val(jQuery('##{part_id} option:last').val())">
      <field-list />
    </formlet>
  </dialog-box>
</def>

Bob Sleys

unread,
Jan 9, 2012, 6:43:17 PM1/9/12
to hobo...@googlegroups.com
One last change.

Changed the <field-list /> to <field-list param /> so I could change the list of fields that show up on the form.

Bob

Bryan Larsen

unread,
Jan 9, 2012, 10:22:33 PM1/9/12
to hobo...@googlegroups.com
OK, I fixed up select-one-or-new-dialog to work as well as it used to.

It still has a couple of major limitations, so it'll probably move out
of hobo-jquery and into -contrib or something as hobo-jquery is
becoming much more 'official' for 1.4.

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/-/Op_geFI5qoIJ.

Bob Sleys

unread,
Jan 10, 2012, 9:58:59 AM1/10/12
to hobo...@googlegroups.com
Thanks Bryan,  however clicking the new button is still submitting the form after poping up the dialog box.  I added an example to abob in my copy of the agility-gitorial.  Simply go to abob add a new one but don't both with the select-one-or-new-dialog since I didn't fix the blank new issues.  Once you have an abob and a few things loaded edit an abob and click the New Thing button to see the problem.

Bob

Bryan Larsen

unread,
Jan 10, 2012, 3:49:08 PM1/10/12
to hobo...@googlegroups.com
Hey Bob, it looks like you didn't customize your controller action as
explained in the documentation. The documentation in the cookbook
should work, but you're better off looking at the comment before the
tag definition at
https://github.com/bryanlarsen/hobo-jquery/blob/no-prototype/taglibs/hobo-jquery.dryml

The need for controller customization is the biggest reason why
select-one-or-new-dialog will probably not make it into Hobo proper
when the rest of hobo-jquery gets merged in to Hobo 1.4.

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/-/ewDZhtGtdw8J.

Bob Sleys

unread,
Jan 10, 2012, 9:15:35 PM1/10/12
to hobo...@googlegroups.com
Ya I knew about that controller change but AFAIK it only came into play on a new record not editing an existing one.  At any rate I added it to the things controller and also added select-one-or-new-dialog to the story_status for Stories ie trying to match the documentation as much as possible.  I'm still having the same problem.  Clicking the new button causes the dialog to appear but then the main form on the page is submitted as if I clicked the submit button.

Bob

Bryan Larsen

unread,
Jan 11, 2012, 11:22:12 AM1/11/12
to hobo...@googlegroups.com
select-one-or-new-dialog always creates a new item, it never does an update.

The fact that you're using it in a form that updates something else is
completely optional, and that controller action is unaffected.

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/-/MGODp2paCokJ.

Bob Sleys

unread,
Jan 11, 2012, 11:49:41 AM1/11/12
to hobo...@googlegroups.com
Ok I guess I'm being confusing and I sorry for that.  Let me try it a different way.

If I have the following dryml

<extend tag="form" for="LocationMaterial">
<old-form merge>
<field-list: fields="material, condition, potential, friable, percent_damage, accessible, quantity, unit, notes">
<material-view:>
<dialog-box id="hello-dialog">
Hello!
</dialog-box>
<dialog-open-button dialog="#hello-dialog">
Press Me!
</dialog-open-button>
</material-view:>
</field-list:>
</old-form>
</extend>

When I click the Press Me! button to display the hello-dialog the dialog popups up but the form is also submitted as if I had clicked the save button at the bottom of the form.  Pressing the button should only display the popup not submit the form.

Bob

Bryan Larsen

unread,
Jan 11, 2012, 12:05:03 PM1/11/12
to hobo...@googlegroups.com
Hmmm, that works for me. What's probably happening is that you have
broken javascript somewhere, stopping the javascript on your page.
Without javascript, buttons revert to their default behaviour which is
to submit their enclosing form.

add onsubmit="return false;" to your form, and then try clicking the
button with firebug or the javascript console running. You should
see a javascript error. Cut & paste that error and backtrace into an
email.

thanks,
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/-/YojYJRskYu0J.

Matt Jones

unread,
Jan 11, 2012, 1:02:38 PM1/11/12
to hobo...@googlegroups.com

Hmmm - at first glance, this sounds like something isn't stopping the button's click event from propagating up to the surrounding form. There may be a missing preventDefault call in the event handler...

--Matt Jones

Bob Sleys

unread,
Jan 11, 2012, 1:56:59 PM1/11/12
to hobo...@googlegroups.com
Ok it sounds like we are getting someplace now :).  I wonder if it's something left over from when I had the old hobo-jquery plugin with prototype.  Adding the onsubmit="return false;" didn't generate a error in the console however did stop the form from being submitted.

Here is the list of javascripts being included into the page.

jquery.js
jquery-ui.js
jquery_ujs.js
hjq.js
hjq-form.js
hjq-formlet.js
hjq-select-many.js
hjq-live-editor.js
hjq-click-editor.js
hjq-datepicker.js
hjq-sortable-collection.js
hjq-delete-button.js
hjq-spinner.js
hjq-filter-menu.js
hjq-autocomplete.js
hjq-input-many.js
hjq-dialog.js
hjq-live-search.js
hjq-search-results.js
hjq-combobox.js
hjq-hot-input.js
hjq-accordion.js
hjq-tabs.js
combobox.js
jquery.form.js
application.js

Bryan Larsen

unread,
Jan 11, 2012, 4:14:26 PM1/11/12
to hobo...@googlegroups.com
Hmmm, that looks like the right list. BTW, Rails 3.1 will turn that
into a single file, so don't worry about the large number of small
files.

Are you up to date? besides bundle update, you also need to do rails
g hobo_jquery:install on an update. Another requirement that should
disappear when we switch to Rails 3.1.

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/-/L0R4c34aXMgJ.

Bob Sleys

unread,
Jan 11, 2012, 8:40:05 PM1/11/12
to hobo...@googlegroups.com
Ya I ran the rails g command again just to be sure but It's still happening.  :(

Bryan Larsen

unread,
Jan 11, 2012, 9:27:13 PM1/11/12
to hobo...@googlegroups.com
Hmmm, I cut & pasted your code into agility and it worked for me
there. Can you make it fail in agility?

thanks,
Bryan

Bob Sleys

unread,
Jan 12, 2012, 7:55:41 AM1/12/12
to hobo...@googlegroups.com
Yup same thing happens there.

Bob Sleys

unread,
Jan 12, 2012, 8:27:51 AM1/12/12
to hobo...@googlegroups.com
Ok I stepped though the javascript when clicking the press me button and here is what I found.  Note I added the highlighted line (return false;)

    $.fn.hjq_dialog_open_button = function(annotations) {
        this.on('click', function() {
            $(annotations.selector).hjq_dialog_box('toggle');
            return false;
        });
    };

This is all called from this section of code in jqury.js starting at line 3319

                    ret = ( specialHandle || handleObj.handler ).apply( matched.elem, args );

                    if ( ret !== undefined ) {
                        event.result = ret;
                        if ( ret === false ) {
                            event.preventDefault();
                            event.stopPropagation();
                        }
                    } 

Since hjq_dialog_open_button has no return the preventDefault is never run.  If I add the return false; to it like above the dialog box opens and the form isn't submitted.

Bob

Bob Sleys

unread,
Jan 12, 2012, 8:35:20 AM1/12/12
to hobo...@googlegroups.com
With the above change in I can now fill out the dialog which is leading to the following error in the logfile

  Processing by StoryStatusesController#create as JS
  Parameters: {"render_options"=>{"preamble"=>"", "contexts_function"=>"hjq.ajax.updatePartContexts"}, "render"=>{"0"=>{"part_context
"=>"BAhbCTokc2VsZWN0X29uZV9vcl9uZXdfZGlhbG9nX3NlbGVjdEkiEHRoaXM6\nc3RhdHVzBjoGRUZbAFsHSSIKc3RvcnkGOwZGSSILc3RhdHVzBjsGRg==--2e2dfb657
5532eac512d39e6113555816cd2f757", "id"=>"select-one-this-status", "function"=>"hjq.ajax.update"}}, "page_path"=>"/projects/1-project-
1/stories/new", "authenticity_token"=>"AiddGRVI5gUM5vtDLI3v5YAK1O+N775FaSBxkQb1bw0=", "story_status"=>{"name"=>"junk99"}}
  User Load (0.6ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
  AREL (0.3ms)  INSERT INTO "story_statuses" ("name", "created_at", "updated_at") VALUES ('junk99', '2012-01-12 13:30:52.484577', '20
12-01-12 13:30:52.484577')
  StoryStatus Load (0.3ms)  SELECT "story_statuses".* FROM "story_statuses"
Call part: select_one_or_new_dialog_select. this-id = this:status, locals = []
         : form_field_path = ["story", "status"]
Completed 500 Internal Server Error in 503ms

ArgumentError (no such class in typed-id: this:status):
  app/controllers/story_statuses_controller.rb:19:in `block (3 levels) in create'
  app/controllers/story_statuses_controller.rb:15:in `block in create'
  app/controllers/story_statuses_controller.rb:10:in `create'

As you can see the new story_status is being created.  this:status ??? should that be a : or a .  ie colon or period?

Bob

Bryan Larsen

unread,
Jan 12, 2012, 10:47:24 AM1/12/12
to hobo...@googlegroups.com
Thanks for tracking it down. It's really strange that it worked for me.

fix committed: https://github.com/bryanlarsen/hobo-jquery/commit/c06ca48b7352912acbab1e8f040170a6524084b7

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/-/H785laVDV3YJ.

Bob Sleys

unread,
Jan 12, 2012, 11:09:55 AM1/12/12
to hobo...@googlegroups.com
Now I'm just down to the crash happening above

It's failing on the hobo_create line in 

  def create
    hobo_create do
      if request.xhr?
        self.this = Story.new
      end


Bob

Bryan Larsen

unread,
Jan 12, 2012, 11:12:39 AM1/12/12
to hobo...@googlegroups.com
this:status is correct. That's the "typed_id" form that Hobo uses.

However, I get story:2:status in my log. Which means I'm testing via
edit.dryml, and you're testing via new.dryml. You try it on
edit.dryml and I'll try it on new.dryml.

cheers,
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/-/8ZxGNDmj2bsJ.

Bryan Larsen

unread,
Jan 12, 2012, 11:55:21 AM1/12/12
to hobo...@googlegroups.com
Two bugs found: one in Hobo, and one in your controller code.

The hobo bug fix is here:
https://github.com/tablatom/hobo/commit/cf36885d5c5fb7348cbc433d291943b24d431c58

The problem with your controller code is that the select-one-or-new is
in new-for-project.dryml, not in new.dryml, so you need to make sure
the story is created on the project.

See https://github.com/Hobo/agility-gitorial/commit/9b5e4eac60e1c93644289fa941654ce037b17e08

for a working example.

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/-/g34j4ibCnTcJ.

Bob Sleys

unread,
Jan 12, 2012, 1:06:56 PM1/12/12
to hobo...@googlegroups.com
Woot got it working in agility now to adapt it to work with my project.  Thanks for all the work.

Bob

Bob Sleys

unread,
Jan 12, 2012, 2:00:10 PM1/12/12
to hobo...@googlegroups.com
I know you are regretting every creating this tag but one more issue I've run across.

If the tag is on a new-page-for it works great.  However if you eliminate the :new in the auto_actions_for so the new form is embedded in the show page you get the following error.  This is of course after making the appropriate change to the params[:page_path] line in the controller.  Not a big deal since I can just move the form to it's own page.

ruby-1.8.7-p352@HazMatTracking/bundler/gems/hobo-cf23915ab1cc/dryml/lib/dryml/part_context.rb:79)
Call part: select_one_or_new_dialog_select. this-id = :unit, locals = []
         : form_field_path = ["location_material", "unit"]
Completed   in 782ms

ArgumentError (invalid typed-id: :unit):
  app/controllers/units_controller.rb:17:in `create'
  app/controllers/units_controller.rb:10:in `create'
  app/controllers/units_controller.rb:8:in `create'


Rendered /home/bsleys/.rvm/gems/ruby-1.8.7-p352@HazMatTracking/gems/actionpack-3.0.7/lib/action_dispatch/middleware/templates/rescues
/_trace.erb (1.1ms)
Rendered /home/bsleys/.rvm/gems/ruby-1.8.7-p352@HazMatTracking/gems/actionpack-3.0.7/lib/action_dispatch/middleware/templates/rescues
/_request_and_response.erb (13.3ms)
Rendered /home/bsleys/.rvm/gems/ruby-1.8.7-p352@HazMatTracking/gems/actionpack-3.0.7/lib/action_dispatch/middleware/templates/rescues
/diagnostics.erb within rescues/layout (18.3ms)

Bryan Larsen

unread,
Jan 12, 2012, 2:27:32 PM1/12/12
to hobo...@googlegroups.com
On Thu, Jan 12, 2012 at 2:00 PM, Bob Sleys <bsl...@gmail.com> wrote:
> I know you are regretting every creating this tag but one more issue I've
> run across.

Hey, no problem. So far we've been finding more bugs in the rest of
hobo-jquery & hobo 1.4 than we have in this really annoying tag.

> Call part: select_one_or_new_dialog_select. this-id = :unit, locals = []
>          : form_field_path = ["location_material", "unit"]

We've run out of magic. :)

The current typed-id format has no way to specify the context. We
definitely could extend the format to support this scenario, but we're
chasing a rabbit hole of diminishing returns here. There's no way
that typed_id could cover every scenario, so we'll just have to be
happy with 99%. If you've got a scenario that justifies an
extension, let us know, though.

cheers,
Bryan

Bob Sleys

unread,
Jan 12, 2012, 2:32:27 PM1/12/12
to hobo...@googlegroups.com
No problem there like I said I can just put the new on a separate page.  I guess it's just something else to add to the limitations of the tag.

Thanks again for all the hard work.  I'm going to be pushing my project up for the uses to test tomorrow now that I've got this tag working.  Lots of new stuff for them to play with.

Thanks
Bob

Bob Sleys

unread,
Jan 13, 2012, 11:48:24 AM1/13/12
to hobo...@googlegroups.com
Just a quick FYI,  I don't know if it's something I've done or what but I've lost the datapicker for date fields.  I did I quick test with the agility-gitorial on adding a foo and I'm not getting it there either.  I haven't had a chance to really look into it yet so I could be something I've done but  have no idea what that might be since I've not changed anything in that area.

Bob
Reply all
Reply to author
Forward
0 new messages