Created
October 18, 2011 04:54
-
-
Save doryokujin/1294636 to your computer and use it in GitHub Desktop.
How to send an javascript event to rails controller within onSelect() function?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/views/*/index.rb.html | |
<% content_for :js do %> | |
$(document).ready(function() { | |
var treeview; | |
var indexes = <%= ActiveSupport::JSON.encode(@indexes).html_safe %>; | |
function onSelect(e) { | |
//alert("Selected: " + indexes[treeview.text(e.node)] ); | |
/* | |
onSelectで要素が選択された時にそれに対するアクションをajaxでなく | |
railsのcontrollerに結びつけられるように記述するにはどうしたら良いのでしょう? | |
ここで選択された要素の名前をrails側に渡して、MongoDBからデータを取得するよう | |
な処理をさせたいです。 | |
<%= f.radio_button :type, 'hoge', | |
{ :onclick => remote_function(:update => "total", :url =>{ :action => 'total_number'}, :submit => :user) } %> | |
的な例はよく見かけますが… | |
*/ | |
}; | |
treeview = $("#treeview").kendoTreeView({ | |
dataSource: <%= ActiveSupport::JSON.encode(@actions).html_safe %>, | |
select: onSelect | |
}).data("kendoTreeView"); | |
}); | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment