1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Submit Form Returns a View on Same Page in #target

Discussion in 'XenForo Development Discussions' started by Marcus, Oct 16, 2013.

  1. Marcus

    Marcus Well-Known Member

    What is the easiest build-in function to submit a form and still stay on the same page? Is there a function like this:
    PHP:
    <div id="target">
      <
    form action="{xen:link pasta}" class="Unknown" data-target="#target"> </form>
    </
    div>
    PHP:
    function actionPasta { return Template 'pasta_list'}
    [code is there to show the idea, not how it really works]
     
  2. Marcus

    Marcus Well-Known Member

    I was thinking about a function like XenForo.Loader, but this time for forms?
     
  3. Chris D

    Chris D XenForo Developer Staff Member

    A class of AutoValidator and an attribute of data-redirect="off" would submit the form without navigating away from that page. You can then use some javascript and AJAX magic to make things happen based on the data being submitted.

    Of course the perfect example of how to do this is profile post comments. The data is submitted via a form, and the end result is rendered without reloading the page.
     
    Marcus likes this.
  4. Marcus

    Marcus Well-Known Member

    Thank you!!
     

Share This Page