Monday, March 24, 2008

Drag and Drop

So I was getting a 'nil object where didn't expect it' error attempting to use the drop_receivable_element helper while working through some tutorials. Yes, I'm going to school for English to be able to write sentences like that. Yes, I know it's a mistake.

The problem is that, like a lot of the magicks underlying Rails, many of the helper methods all call each other. At some point in the development process, after the writing of the above tutorial I assume, drop_receivable was modified to call some of the link helpers.

The assumption is that if you have such an ajax drop-able area, you're going to want to fire off a request to some controller somewhere, and so why not make the link mandatory? While that's all well and good, there should probably be some sort of dignified way to 'opt-out' of this sort of thing.

You can add a quick hack to get around it if you specify :url => '#' in the options hash. Mine looked like this:

<%= drop_receivable_element(:dropDIV , {:url => '#', :hoverclass => :hover}) %>

Also, I understand that we can strip out 'parameter punctuation' to make things more streamlined? I mean, I know that drop_receivable_element :dropDIV, :url => '#', :hoverclass => :hover might fit more into in-line text... but I always thought that the extra symbols were good to help break the code up a bit more and make it more maintainable.

Anyway, I'm going to be doing some more work later on this week to get drag-and-drop working in 2d space, the first step in getting a web-based, virtual tabletop off and running.

0 Comments:

Post a Comment

<< Home