javascript - How to render an existing template as a popup form on a separate page on the click of button? -


i making web app using django, have template contains form needs filled user, want provide option user can fill form separate template means of button on template, clicking on button displays original form popup form. able open original form on button click on separate window not popup on same page.

i know use jquery , ajax i'm not sure how implement it.

you should separate template form two:

form.html {# usual header , containers work on separate page correctly #} ... {% includes "your_app/includes/ajax_form.html" %} ....  ajax_form.html {# form here or container sent via ajax #} <form ...> </form> 

also inside template want have popup should again include ajax_form.html template. don't forget set correct action in form send requests formview.

then have create view overriden get_template_names method:

class yourformview(formview):     ...     def get_template_names(self):         if self.request.is_ajax():             return ['your_app/includes/ajax_form.html']         return ['your_app/form.html'] 

usual request - complete template returned. ajax request - form template returned.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -