Skip to content

Problem submitting a form #647

Open
Open
@cccaballero

Description

@cccaballero

Hi, I am defining a pjax container in that way:

$.pjax({
            async: false,
            push: false,
            url: "http://theurl.com/form",
            container: ".pjax-component[data-pjax-component-id='123']",
            timeout: 30000,
        });

It loads well the url (which contains a form), and I am implementing the form submission in that way:

// trap form submit
$(document).on('submit', ".pjax-component[data-pjax-component-id='123'] form", function(event) {
    event.preventDefault(); // stop default submit behavior
    $.pjax.submit(event, ".pjax-component[data-pjax-component-id='123']");
});

When the form is sumitted it reloads the whole page. I track the problem to the handleSubmit() function, it gets a null options value, and the optionsFor() function returns an options object with "http://theurl.com/#" as url value, when it should be "http://theurl.com/form", in fact, if I add the line:

options.url = "http://theurl.com/form";

to the handleSubmit() function, it works well (only for that container, of course)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions