it was made in rails 2 but it’s works fine for me on rails 3… i fix some
problems in my migration to rails 3, but it was easy
try thishttps://github.com/springbok/jqgrid-rails3
It’s for rails 3
It should be clear by now that gems/plugins for javascript generation are to
be avoided. Not only will it generate ugly inline code in most cases, but
you also lose a lot of control. If you want to use Javascript, then write
Javascript, don’t let some ruby gem write the code for you.
I’m trying using the pure jquery jqgrid.
I’ve write the javascript code to display a datagrid, I get the code
from jqgrid demos jqGrid Demos.
Now I have great problem to take data from a rails model.
I don’t know how and there isn’t examples.
Have Rails put the data in the DOM. Have the JS read it. Done.
On 13 January 2011 15:07, Marnen Laibow-Koser [email protected]
wrote:
read it?
Or is something else confusing you?
It’s not clear to me how put data in the DOM
You’ve probably put data in the DOM thousands of times using Rails. The
DOM is simply the document represented by the HTML that Rails generates.
You already know how to put data in the HTML generated by Rails, right?
and how to read.
With any of the myriad JS functions for that purpose (such as
Element.innerHTML…)
Sorry for my ignorance.
No apology is necessary for ignorance. Apology is only necessary if
you’re not using the knowledge you do have.
(i.e., pretty much all the time) you are putting that content into the DOM
or classname or some other common denominator, you use $$(‘div.foo’) or
I believe that jQuery is similar to Prototype in syntax and construction.
You may find an easier path to answers by looking up the library
documentation on their very glossy site.
It’s not clear to me how put data in the DOM and how to read.
Sorry for my ignorance.
Whenever you have Rails create HTML content and serve it to the
browser (i.e., pretty much all the time) you are putting that content
into the DOM (Document Object Model) of the browser. Now if you place
some content above the visible page using CSS, or simply set it to
display:none, it will still be in the DOM, but it will be hiding and
waiting for you to do something with it subsequently using JavaScript.
In Prototype, you most easily access a single HTML element (like a
DIV) using the $(‘theIdOfTheElement’) shortcut for the native JS
getElementById(id) construct.
If you want to access a collection of elements that have the same tag
name or classname or some other common denominator, you use $$
(‘div.foo’) or similar. That gets you an enumerable collection, which
you iterate using each(), just like in Ruby.
If you want to grab the content of a DIV, or show it from its hidden
state, or make it bound around the window like a terrified mountain
goat, you can do that once it’s in the DOM.
You can also access content from your server using an Ajax call, and
either directly replace any element in the page, or use that content
as variable data to further modify your page.
I believe that jQuery is similar to Prototype in syntax and
construction. You may find an easier path to answers by looking up the
library documentation on their very glossy site.