Skip to content

Commit

Permalink
Form submission works for task list widget.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtopher committed Jun 28, 2013
1 parent 61ce53c commit 31f5e7a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
13 changes: 9 additions & 4 deletions themes/third_party/dashee/js/dashee.js
Expand Up @@ -498,7 +498,7 @@ $(function() {
}, this));

// Event to handle widget form submissions.
$('.wgt_form').on('submit', function (e) {
$(document).on('submit', '.wgt_form', function (e) {
e.preventDefault();

var $widget = $(this).parents('li');
Expand All @@ -510,10 +510,15 @@ $(function() {
data: $(this).serialize() + '&wgtid=' + $widget_id,
success: function(html) {
var $result = $.parseJSON(html);
$('h2', $widget).html($result.title);
$widget.find('.widget-content').html($result.content);

$.ee_notice($result.message, {type: 'success', open: true});
if($result.type == 'success') {
$('h2', $widget).html($result.title);
$widget.find('.widget-content').html($result.content);
$.ee_notice($result.message, {type: 'success', open: true});
}
else {
$.ee_notice($result.message, {type: 'error', open: true});
}
},
error: function(html) {
$.ee_notice("Nope, there was a problem.", {type: 'error', open: true});
Expand Down
12 changes: 8 additions & 4 deletions third_party/dashee/mcp.dashee.php
Expand Up @@ -799,18 +799,22 @@ public function ajax_widget_proxy()

$content = $obj->index(@json_decode($this->_widgets[$wgtid]['stng']));
$result = array(
'type' => 'success',
'title' => $obj->title,
'content' => $content,
'message' => $message
);

echo json_encode($result);
exit();
}
else
{
echo 'aw crap';
$result = array(
'type' => 'failure',
'message' => 'Something went wrong.'
);
}

echo json_encode($result);
exit();
}

/**
Expand Down

0 comments on commit 31f5e7a

Please sign in to comment.