//Preview need a link in form as Ex and a corresponding PUT action in controller
//Ex preview trigger:
// <%= link_to "NewPreview", realtime_preview_admin_ad_banner_path(ad_banner_tab) , :class=>'preview_trigger'%>
$(document).ready(function() {
$("a.post_preview").click(function(e){
$("#main-wrap").after("");
e.preventDefault();
var form = $(this).parents("form").first()
//var cont = form["content"].value;
$.ajax({
type: 'POST',
url: $(this).attr("href")+'?preview=true',
data: form.serialize(),
dataType: "script",
success: function (msg) {
$("#"+start_modal_with_id).modal('show'); },
error: function(){
alert("ERROR");
}
});
return false
});
$("a.preview_trigger").click(function(){
$("#main-wrap").after("");
$.ajax({
type: 'PUT',
url:$(this).attr("href"),
data:$(this).parents("form").serialize(),
success: function (msg) {
$("#"+start_modal_with_id).modal('show'); },
error: function(){
alert("ERROR");
}
});
return false;
});
});