[virtualcommons-svn] commit/vcweb: RoleeSinha: fixing KO binding
Status: Beta
                
                Brought to you by:
                
                    alllee
                    
                
            | 
     
      
      
      From: <com...@bi...> - 2013-05-14 21:49:17
      
     
   | 
1 new commit in vcweb: https://bitbucket.org/virtualcommons/vcweb/commits/f9fd2bc64f10/ Changeset: f9fd2bc64f10 User: RoleeSinha Date: 2013-05-14 23:48:53 Summary: fixing KO binding Affected #: 1 file diff -r 0b24e46febd915cd194444646ab3a0d10f700db3 -r f9fd2bc64f1001752928ddb3291f0978966ee9be vcweb/lighterprints/templates/lighterprints/mobile/index.html --- a/vcweb/lighterprints/templates/lighterprints/mobile/index.html +++ b/vcweb/lighterprints/templates/lighterprints/mobile/index.html @@ -23,47 +23,49 @@ <script> $(document).on('pageinit', function(event){ var viewModelData = $.parseJSON("{{view_model_json|escapejs}}"); - var viewModel = new LighterFootprintsModel(viewModelData); - viewModel.perform = function(challengeModel){ - if (!challengeModel.availableNow()) { - console.debug("tried to perform an activity that's not available right now"); - console.debug(challengeModel); - return; - } - var id = challengeModel.pk(); - var formData = { - participant_group_id: viewModel.participantGroupId(), activity_id:id - }; - $.post('/lighterprints/api/do-activity', formData, function(data){ - if (data.success) { - console.debug(data); - //$('#dashboardPage').trigger('pagecreate'); - ko.mapping.fromJSON(data.viewModel, viewModel); - viewModel.lastPerformedActivity(challengeModel); - ko.applyBindings(viewModel); - //$.mobile.changePage("/lighterprints/mobile"); - $("#popupDialog").popup('open'); - console.debug('refreshing lists'); - $('#challengesList').listview('refresh'); - $('#teamList').listview('refresh'); - $('#teamActivityList').listview('refresh'); - } - else { - console.debug("ERROR: " + data.message); - } - }) - }; - - viewModel.send = function(){ - if ($('#chatText').val()) { - var formData = {participant_group_id: viewModel.participantGroupId(), message:$('#chatText').val()}; + var viewModel = new LighterFootprintsModel(viewModelData); + viewModel.perform = function(challengeModel){ + if (!challengeModel.availableNow()) { + console.debug("tried to perform an activity that's not available right now"); + console.debug(challengeModel); + return; + } + var id = challengeModel.pk(); + var formData = { + participant_group_id: viewModel.participantGroupId(), + activity_id: id + }; + $.post('/lighterprints/api/do-activity', formData, function(data){ + if (data.success) { + console.debug(data); + ko.mapping.fromJSON(data.viewModel, viewModel); + viewModel.lastPerformedActivity(challengeModel); + ko.applyBindings(viewModel); + $("#popupDialog").popup('open'); + console.debug('refreshing lists'); + $('#challengesList').listview('refresh'); + $('#teamList').listview('refresh'); + $('#teamActivityList').listview('refresh'); + } + else { + console.debug("ERROR: " + data.message); + } + }) + }; + + viewModel.send = function(){ + if ($('#chatText').val()) { + var formData = { + participant_group_id: viewModel.participantGroupId(), + message: $('#chatText').val() + }; $.post('/lighterprints/api/message', formData, function(response){ if (response.success) { console.debug("successful post - updated view model: "); ko.mapping.fromJS(response.viewModel, viewModel); - ko.applyBindings(viewModel); - console.debug('refresh chatMessage List'); - $('#chatMessageList').listview('refresh'); + ko.applyBindings(viewModel); + console.debug('refresh chatMessage List'); + $('#chatMessageList').listview('refresh'); } else { console.debug("unable to post message to server"); @@ -72,28 +74,19 @@ }); $('#chatText').val(''); } - }; + }; + ko.applyBindings(viewModel); + $("#dashboardPage").on('pageshow', function(event){ + console.debug('dashboardPage pageshow'); + $('#challengesList').listview('refresh'); + $('#teamList').listview('refresh'); + $('#teamActivityList').listview('refresh'); + }); - ko.applyBindings(viewModel); - //ko.applyBindings(globalViewModel, document.getElementById("dashboardPage")); - //ko.applyBindings(globalViewModel, document.getElementById("myTeamPage")); - - //$("#myTeamPage").on("pagebeforeshow", function() { - // ko.applyBindings(globalViewModel); - //}); - $("#dashboardPage").on('pageshow', function(event){ - console.debug('dashboardPage pageshow'); - ko.applyBindings(viewModel); - $('#challengesList').listview('refresh'); - $('#teamList').listview('refresh'); - $('#teamActivityList').listview('refresh'); - }); - $("#myTeamPage").on('pageshow', function(event){ - ko.applyBindings(viewModel); - $('#myTeamPage').trigger('pagecreate'); - console.debug('myTeamPage pageshow'); - $('#chatMessageList').listview('refresh'); - }); + $("#myTeamPage").on('pageshow', function(event){ + console.debug('myTeamPage pageshow'); + $('#chatMessageList').listview('refresh'); + }); }); </script><!-- knockout templates --> Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.  |