Page Preview Problem after changing layuot

0 views
Skip to first unread message

Amruta

unread,
Jul 23, 2009, 1:10:07 AM7/23/09
to Comatose Plugin
This java script function is from comatose_admin.js(Line number 174)
used to show page preview.

// Uses server to create preview of content...
preview_content : function(preview_url) {
$('preview-area').show();
var params = Form.serialize(document.forms[0]);
if( params != this.last_preview ) {
$('preview-panel').innerHTML = "<span
style='color:blue;'>Loading Preview...</span>";
new Ajax.Updater(
'preview-panel',
preview_url,
{ parameters: params }
);
}
this.last_preview = params;
},
cancel : function(url) {
var current_data = Form.serialize(document.forms[0]);
var data_changed = (this.default_data != current_data)
if(data_changed) {
if( confirm('Changes detected. You will lose all the updates you
have made if you proceed...') ) {
location.href = url;
}
} else {
location.href = url;
}

}
}
I have changed layout of comatose in my application. I am getting two
forms on edit page. First one is for switch role where I am getting
params[:role] and second one is form for comatose page where I am
getting params[:page].
In code
var params = Form.serialize(document.forms[0]);
index 0 is hard coded.Edit option was not showing me page preview as
my comatose page form index is 1 n not 0.
To solve this issue I passed id 'form_edit' to form in _form.html.erb
form_for :page, @page,:html => { :id => 'form_edit' } do |f|
end
Done changes in java script function as

var params = Form.serialize('form_edit');

Noe its working fine.I just want to know is there a right way to solve
this problem.I think there should not any hard coded index in plug-
in's source code.Form should be identified with its id and not by
index.
Reply all
Reply to author
Forward
0 new messages