If I look at a page with a Scriptaculous example like:
http://www.gregphoto.net/sortable/advanced/
And I can view the html/js source of the page -- my question becomes, how do I implement this, or wire this into, my rails app? -Janna B
If I look at a page with a Scriptaculous example like:
http://www.gregphoto.net/sortable/advanced/
And I can view the html/js source of the page -- my question becomes, how do I implement this, or wire this into, my rails app? -Janna B
You need to , one way or another, generate the javascript that sets up the scriptaculous stuff (ie create instances of Sortable for appropriate dom elements and so on). There are helpers (draggable_element and so ) that sort of do this for you but personally I feel that most of that stuff is a bit of a crutch and that you'd be better off biting the bullet and learning enough javascript/scriptaculous that you can just write it on your own.
Fred
Thanks Fred, Yes, this is immensely frustrating -- I've lost 3 days working on this, and looking at examples that don;t cut it -- there is a vacuum of documentation really, and it seems to be a very RoR thing "Yes, this is fast and easy to do in RoR with this library/plugin/gem," but when you go to actually do it, you are left with total trial and error.
No wonder the dork frameworks like Java Struts are so much more prevelant. In truth, those frameworks may just be faster and easier to use -- I've been trying to accomplish things here that frankly don;t pay off in terms of the time curve. No one seems to know how to use the Scritpatuclous library's aside from mickey mouse effects.
-Janna B.
And I further agree with you -- I think we all need to bite the bullet and become js experts rather than depending on Rails to do it for us. The problem is, if I look at all this JS that I am seeing in this example, I am trying to discern where in my rails app I pick up these values? -Janna B.
Janna, this was mentioned at Railsconf 2009 during the Rails Core
Panel talk. It was actually the second question from the start of the
talk. In short, one should understand the underlying technologies
instead of trying to always abstracting it away.
-Conrad
Exactly -- or so I am learning. Look, the scriptaculous stuff. for instance, is laden with examples. Trying to do the same thing in rails, though purported to be "easier," and more expeditious, is actually a complete pain -- the absence of exampls & documentation really holds you back and squanders my time. Heneforth, as a matter of design philosophy, I think we are FAR better tos stick to html/ javascript/css and only use rails to tie back into on the server side.
THAT SAID....I am wondering where I tie rails into the source on:
http://www.gregphoto.net/sortable/advanced/
and if I cannot tie into it somehow, easily, might as well find a different mechanism than RoR -- to my way of thinking and my limited experience with RoR, if it cannot at least do that easily, it's pointless to pursue as a viable platform for web development. -Janna B.
Exactly -- or so I am learning. Look, the scriptaculous stuff. for instance, is laden with examples. Trying to do the same thing in rails, though purported to be "easier," and more expeditious, is actually a complete pain -- the absence of exampls & documentation really holds you back and squanders my time. Heneforth, as a matter of design philosophy, I think we are FAR better tos stick to html/ javascript/css and only use rails to tie back into on the server side.
THAT SAID....I am wondering where I tie rails into the source on:
and if I cannot tie into it somehow, easily, might as well find a different mechanism than RoR -- to my way of thinking and my limited experience with RoR, if it cannot at least do that easily, it's pointless to pursue as a viable platform for web development. -Janna B.
At the end of the day, Rails is mostly a server side thing. In any sensible world your choice of front end tools (javascript libraries and so on) doesn't impact on the backend (be it rails, a php framework etc.).
Making a list like that with items from your app doesn't require big chunks of integration. create the html for the list items as you would for a completely static display (just ensuring that each element has a DOM id). Then you need to run the javascript that will setup the scriptaculous side of things. If you want to do exactly what that example website does then you might have to generate some javascript yourself (rails can make the script tags for you but then you need to fill in the blanks), or if what you want is what the scriptaculous helpers do then something like
<%= sortable_element 'message_list', :url => sort_things_path, :complete=> visual_effect(:highlight, 'message_list'), :tag => 'div'%>
will do the trick.
Fred
Thank all of you gentleman very much. As I read your suggestions, it occurs to me that I have perhaps not modelled what I need to do smartly -- and that is making this further complicated. I have a number of models which I need t ocombine into a view. For instance, I have an players model, which I need to make a list of (batting order) (which is what I want to be able to drag into from the team, and out of), this list to occur on the left side of the view, and in the center, I will put rows containing informations (my info 'model' class) that have occured throughout the game, with various link_to's in he informations.
So I have all these data models that I must put into one composited view. And I am really lost now how one might do this in rails. I do not have a model for this compositied view (though, I could make one -- consistening of two arrays) but then how would I save all this in the db (right now I have info and player model) and the fact that the data for this composited view doesn;t need to be persisted. This really is at the core of my problems here I suppose - and I have no idea how to set this up. -Janna B