1

I try to make channel form submit via ajax, but stuck now. I have a page showing the list of channel entries, when user clicks on edit link, which is next to each entry, it shows a panel () which contains template partial where I have the channel form. Simply when user clicks on the edit link, it just calls:

$('#contentedit').load('/malls/_editmall/' + id);
$('#paneledit').toggle('slide', { direction: 'right' });

where I have template partial is _editmall. And the code in the partial is as follows:

<div id="entry-body">
  {exp:channel:form channel="malls" include_jquery="no" json="yes" entry_id="{segment_3}"}
    <label for="title">Title</label>
    <input type="text" name="title" id="title" value="{title}" size="50" maxlength="100" onkeyup="liveUrlTitle();">
    <label for="url_title">URL Title</label>
    <input type="text" name="url_title" id="url_title" value="{url_title}" maxlength="75" size="50">
    <input type="submit" name="submit" value="Submit">
  {/exp:channel:form}
</div>

I put the following code in the example to the main template (I tried also in partial though),

<script type="text/javascript">
    $(document).ready(function() {
        $('#publishForm').ajaxForm({
            dataType: 'json',
            success: function(data) {
                if (data.success) {
                    // success!
                } else {
                    console.log(data);
                }
            }
        });
    });
</script>

So I expect that the page will just save and stay in the page as it is. But instead it opens the url of the partial, and shows the json (success) on the page. And yes, I have reference to both jquery and jquery form plugin.

You can see my page here

Any idea what I'm doing wrong?

1
  • Unable to see the edit link. I guess I have to login? Have you tried a return false; after your conditional if (data.success)?
    – Bransin
    Jun 24, 2014 at 2:15

2 Answers 2

0

Have you tried ajaxForm at it's most simple state?

 $('#publishForm').ajaxForm(function() { 
     alert("Thank you for your comment!"); 
 }); 

Try that and on your exp tag take json="yes" off.

0

I think you may need to also add include_assets="no"

HIH.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.