私の見解では、パーシャルを置き換えるための UJS がいくつかあります。.js ファイルは次のようになります。
transition("#content_container", "<%= escape_javascript(render 'users/show') %>");
librarySorter("User", "<%= @user.username %>");
遷移関数は期待どおりに実行されますが、librarySorter は実行されていません。firebug をチェックインすると、応答に次のように表示されます。
librarySorter("User", "tbaron");
さらに奇妙なことに、その行をコピーして Firebug コンソールに貼り付けると、正しく実行され、実行されます。私はこれを何時間もいじっていますが、なぜ機能しないのかまだわかりません。何か案は?
参考までに、librarySorter は次のようになります (application.js にあります)。
function librarySorter(library_type, id){
function publication_sort_binder(type, order, name){
$("#overview_table").animate({opacity: 0}, 400);
$("#sort_method").html(type+' '+order);
var url = library_type == "User" ? '/users/'+id+'/owned_publications' : '/groups/'+id+'/overview_sort'
$.ajax({
type: 'GET',
data: {'function':type+' '+order},
url: url,
success: function() {
$("#publication_sort_arrow").remove();
var arrow = (order == 'ASC') ? '↓' : '↑';
$('#sort_'+name).unbind("click").click(function() {
publication_sort_binder(type, (order == 'ASC') ? 'DESC' : 'ASC', name);
}).append("<span id='publication_sort_arrow'> "+arrow+"</span>");
}
});
}
$('#sort_title').click(function() {
publication_sort_binder("publications.title", "DESC", "title");
})
$('#sort_author').click(function() {
publication_sort_binder("contributors.name", "DESC", "author");
})
$('#sort_review_date').click(function() {
publication_sort_binder("reviews.created_at", "DESC", "review_date");
})
$('#sort_review_vote').click(function() {
publication_sort_binder("reviews.votes_sum", "DESC", "review_vote");
})
$('#sort_children_total').click(function() {
publication_sort_binder("updates.replies_count", "DESC", "children_total");
})
}