开发者

Django Flowplayer overlay does not submit form

开发者 https://www.devze.com 2023-03-13 22:17 出处:网络
I am trying to use flowplayer\'s overlayto load an external page that has a django form built in. However the overlay loads the page but the submit button simply refreshes the page.

I am trying to use flowplayer's overlay to load an external page that has a django form built in.

However the overlay loads the page but the submit button simply refreshes the page.

How do i actually submit the values entered in the form?

  <script src="http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js"></script>
        <script>

$(function() {

    // if the function argument is given to overlay,
    // it is assumed to be the onBeforeLoad event listener
    $("a[rel]").overlay({

        mask: {
            color: '#ebecff',
            loadSpeed: 200,
            opacity: 0.9
        },
        effect: 'apple',

        closeOnClick: false,


        onBeforeLoad: function() {

            // grab wrapper element inside content
            var wrap = this.getOverlay().find(".contentWrap");

            // load the page specified in the trigger
            wrap.load(this.getTrigger().attr("href"));
        }

    });
});
</script>

<div class="bananas"><a 开发者_JS百科href="../boom/" rel="#overlay" class="red">launch</a></div>

my view boom has a model form.


Without seeing the actual view code, it's hard to give a helpful answer. In the future, please be sure to do so...

If you don't have the overlay programmed to redirect to the page, then submitting it to that same url might process/save the data without you noticing. Is the data being saved, or does absolutely nothing happen when you click 'submit'?

Generally, this is how it works: you need to be posting to a url, defined in urls.py, that points to a view function in your views.py. (These names are merely convention, and can be called whatever you like) You mentioned that you have a view named 'boom': is it defined in your urls.py like this?

url(r'^path/to/boom/$', 'model.views.boom',),

Check that this is defined and that your form is posting to it.

The view must then contain logic to process the request and return a response. Posting to that url will transfer a cleaned_data dictionary of form variables that can be accessed over the field names defined in the form. It looks like this: x = form.cleaned_data[x]. Check the form for its validity with form.is_valid(), and then do your processing. This can involve saving objects, running arbitrary code, whatever you wish.

To find out more, be sure to read the excellent documentation.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号