Reputation: 3782
I am making a blog app in Django and I want to do the following things
How can I do this?
Edit: As told in the answer below I am trying to use this code snippet to open it in a new window, but this does not work
<script>
var current_link = $(location).attr('href');
$('.preview_button').onClick(function() {
window.open(current_link,'preview_tab');
});
</script>
Also I currently have 3 submit buttons and I want to provide this feature only for 1 submit button i.e. preview So I cannot directly do (#form).onSubmit
. For the the other two buttons, one updates the content via Ajax and the other redirects to a new page.
Upvotes: 1
Views: 4991
Reputation: 28846
Try using a Javascript onSubmit
to open the appropriate preview page with window.open
, passing a name as the second parameter. It does almost exactly that. (If you want to support having different preview tabs associated with different editing tabs, include something in the name based on a tab ID of some kind -- maybe the article ID plus a random number, or something.)
You'll have to also send the updated content into the server via AJAX.
Upvotes: 2