Live-tree javascript call to db?

Hiya,

Sorry if this is a daft question but it’s driving me insane. I have:

:on_click_item => “treeOnClickItem(this, item.id, item.isLeaf, item.code
)”

as an option for a tree (implemented by the live-tree plugin) but I need
the item.code to be a find statement to a model. Within that statement
is there a way to call to the model/db?

Thanks so much for help!
Bex

Becky F. wrote:

Sorry if this is a daft question but it’s driving me insane. I have:

:on_click_item => “treeOnClickItem(this, item.id, item.isLeaf, item.code
)”

as an option for a tree (implemented by the live-tree plugin) but I need
the item.code to be a find statement to a model. Within that statement
is there a way to call to the model/db?

I’m not familiar with the live-tree plugin, so this is a bit of a shot
in the dark, but that string looks like Javascript code that’s being
written out to the browser somewhere.

So if this is the find statement:

@my_code = Bakery.find(:conditions => “bagels IS NULL”).code

(or whatever) then try sticking that result into the code using
standard string interpolation:

:on_click_item => “treeOnClickItem(this, item.id, item.isLeaf,
#{@my_code})”

Chris