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?