Permalink
Browse files

js only parse json response; bump to 0.1.6

  • Loading branch information...
1 parent 2b79aa8 commit a5be811bf6bc87b9db0f7d7a2a6281ecbc593b58 @jgerigmeyer committed Oct 5, 2012
Showing with 23 additions and 11 deletions.
  1. +5 −0 CHANGES.rst
  2. +1 −1 LICENSE.txt
  3. +1 −1 messages_ui/__init__.py
  4. +16 −9 messages_ui/static/messages_ui/jquery.messages-ui.js
View
@@ -1,6 +1,11 @@
CHANGES
=======
+0.1.6 (2012.10.05)
+------------------
+
+* JS don't parse non-json.
+
0.1.5 (2012.07.23)
------------------
View
@@ -1,4 +1,4 @@
-Copyright (c) 2011, Jonny Gerig Meyer
+Copyright (c) 2012, Jonny Gerig Meyer
All rights reserved.
Redistribution and use in source and binary forms, with or without
View
@@ -1 +1 @@
-__version__ = "0.1.5"
+__version__ = "0.1.6"
@@ -1,5 +1,5 @@
/**
- * jQuery Messages UI 0.1.4
+ * jQuery Messages UI 0.1.6
*
* Copyright (c) 2011, Jonny Gerig Meyer
* All rights reserved.
@@ -44,15 +44,22 @@
}
if (options.handleAjax) {
$.ajaxSetup({
- dataType: "json",
+ dataType: 'json',
dataFilter: function (data, type) {
- if (type === "json") {
- var parsed = $.parseJSON(data),
- messages = $(parsed.messages);
- messages.each(function () {
- $(ich.message(this)).appendTo(messageList);
- });
- messageList.messages();
+ if (data && type === 'json') {
+ var json;
+ try {
+ json = $.parseJSON(data);
+ } catch (e) {
+ json = false;
+ }
+ if (json && json.messages) {
+ var messages = $(json.messages);
+ messages.each(function () {
+ $(ich.message(this)).appendTo(messageList);
+ });
+ messageList.messages();
+ }
}
return data;
}

0 comments on commit a5be811

Please sign in to comment.