[view]
function ajax_create(act, pos, goals) {
$.ajax({
url: '/goals/'+act,
type: 'POST',
data: goals,
dataType: 'html',
success:function(html){
$(pos).after(html);
$('td.goal_del').unbind('click', goal_del).bind('click', goal_del);
$('td.goal_up_tmp').unbind('click', goal_up ).bind('click', goal_up);
$('td.goal_down_tmp').unbind('click', goal_down).bind('click', goal_down);
}
});
}
[controller]
render :partial => 'member/temp_goal', :locals => {:g => new_goal}
[view]
<%= observe_field :target_type_target_type_id, :on => "change",
:url => {:action => :update_target_list},
:with => "{target_type_id: value, target_cat_id: $('target_type_target_cat_id').value}"%>
(用page 寫 js)
[controller]
render :update do |page|
page.replace_html 'target_type_target_id', :partial => 'target_type_select', :locals => {:types => target_list}
end
[view]
function test() {
$.ajax({
url: '/alert/test',
type: 'GET',
success : function(html){
alert(html);
}
});
}
[controller]
render :action => 'test', :layout => false
[test view]
<% response.headers['Content-Type'] = "text/javascript" %>
alert(<%=1+1 %>);
[view]
function test() {
$.ajax({
url: '/alert/test',
type: 'GET',
dataType: 'script'
});
}
[controller]
render :action => 'test', :layout => false
[test view]
<% response.headers['Content-Type'] = "text/javascript" %>
alert(<%=1+1 %>);
[view]
function test() {
$.ajax({
url: '/alert/test',
type: 'GET',
dataType: 'script'
});
}
[controller]
render :update do |page|
page.alert('cccccc') #page << "alert('cccc');" the same end
[view]
function test() {
$.ajax({
url: '/alert/test',
type: 'GET',
dataType: 'script'
});
}
[controller]
def test
#nothing
end
[test view] test.rjs
page << "alert('cccccc');"
2008年9月4日 星期四
render page update
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言