Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix bug cannot get list from server if local database is empty.

  • Loading branch information...
commit 1b708f53c122a74ea0d9978c22ae3c1ad777e229 1 parent 7bbc609
@swznd swznd authored
Showing with 24 additions and 8 deletions.
  1. +24 −8 js/events.js
View
32 js/events.js
@@ -23,11 +23,15 @@ this.events = (function() {
}
else {
if(window.navigator.onLine) {
- api.items('', function(data) {
- if(data) {
- add(data);
- showList();
- }
+ $('#view-event-list-status').show();
+ user.getToken(function(token) {
+ api.items('', token, function(data) {
+ if(data) {
+ add(data);
+ showList();
+ $('#view-event-list-status').hide();
+ }
+ });
});
}
else {
@@ -126,6 +130,8 @@ this.events = (function() {
$('#detail-description').text(data.description);
+ console.log(data.is_attend);
+
if(data.is_attend) {
$('#detail-meta input[type="checkbox"]').attr('checked','checked');
}
@@ -379,12 +385,22 @@ $(function() {
$('#detail-attend').click(function() {
var type = $(this).is(':checked') ? 'attend' : 'unattend';
- user.setAttend($('#view-event-detail').attr('data-eventid'),type,function() {
+ user.setAttend($('#view-event-detail').attr('data-eventid'),type,function(ret) {
if(type == 'attend') {
- $('#detail-attend').attr('checked');
+ if(ret) {
+ $('#detail-attend').attr('checked','checked');
+ }
+ else {
+ $('#detail-attend').removeAttr('checked');
+ }
}
else {
- $('#detail-attend').removeAttr('checked');
+ if(ret) {
+ $('#detail-attend').removeAttr('checked');
+ }
+ else {
+ $('#detail-attend').attr('checked','checked');
+ }
}
})
})
Please sign in to comment.
Something went wrong with that request. Please try again.