Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

How to close detail windows so they don't pile up in stack

$
0
0

I am close to having some new functionality built in my app to display student grades and have one problem that has me stumped. The first step is for the student to select the applicable semester. Once they click on the desired semester, a new window displays with the grades (and supporting information) for the courses in that semester. All this works greats the first time, but when you hit the back button (in android) and select another semester the grades detail page displays appropriately, but when you click the back button this time, it first displays another grades detail window (with the new semester info). Each time you do this, there is another window you have to click through to get to the semester page. They are obviously not being cleaned up when clicking the back button and are just being added to the stack. I've tried everything I can think of and done a lot of research, but I just can't seem to find an answer. I'll present the three js files (semesterTerms, grades, and gradesRow) below. Any ideas on this would be greatly appreciated. I'm afraid I'm still not fully understanding window and memory management concepts yet.

semesterTerms.js

function getSemesterTerms() {
  var openMode = 'Grades';
  var data = [];
  var request = Titanium.Network.createHTTPClient();
  request.open("POST","https://www2.sites.uidaho.edu/uimobile/webservices.aspx/GetLastPayStub?t=6");
  request.send();
  request.onload = function() {
    var content = JSON.parse(this.responseText);
    var results = content.results;
    for (var i = 0; i < content.length; i++) {
 
      data.push(Alloy.createController("semesterRows", {   
        term        : content[i].Id,   
        description : content[i].Description,   
        dateRange   : content[i].DateRange   
 
      }).getView());   
 
      Ti.API.info(content[i].Id);   
      Ti.API.info(content[i].Description);   
      Ti.API.info(content[i].DateRange);   
 
    }   
 
    $.termsview.setData(data); 
 
    openMode = Alloy.Globals.getOpenMode();
 
    Ti.API.info(openMode); 
 
    $.termsview.addEventListener("click",function(e) {
      if (openMode == 'Grades') {
        Alloy.Globals.setSelectedTerm (content[e.index].Id);
        var grades = Alloy.createController('grades').getView();
        grades.open();
      }
      else if (openMode == 'Courses') {
        Alloy.Globals.setSelectedTerm (content[e.index].Id);
        var courses = Alloy.createController('courses').getView();
        courses.open();
      }
 
    });
 
  };
 
};
 
$.semesterTerms.open();
grades.js
function getGrades() {
  var selectedTerm = Alloy.Globals.getSelectedTerm();
  var data = [];
  var request = Titanium.Network.createHTTPClient();
  request.open("POST","https://www2.sites.uidaho.edu/uimobile/webservices.aspx/Page_Load?t=7&term="+selectedTerm);
  request.send();
  request.onload = function() {
    var content = JSON.parse(this.responseText);
    var results = content.results;
    for (var i = 0; i < content.length; i++) {
 
      data.push(Alloy.createController("gradeRows", {   
        crnKey              : content[i].CrnKey,   
        subjectCode         : content[i].SubjectCode,   
        courseNumber        : content[i].CourseNumber,   
        gradeCode           : content[i].GradeCode,   
        totalCreditHours    : content[i].TotalCreditHours,   
        sectionNumber       : content[i].SectionNumber,   
        instructorFirstName : content[i].InstructorFirstName,   
        courseTitle         : content[i].CourseTitle,   
      }).getView());   
 
    }   
 
    $.gradesview.setData(data); 
 
  };
 
};
gradeRows.js
var args = arguments[0] || {};
 
$.crnKey.text               = args.crnKey;   
$.subjectCode.text          = args.subjectCode;
$.courseNumber.text         = args.courseNumber;   
$.gradeCode.text            = args.gradeCode;   
$.totalCreditHours.text     = args.totalCreditHours;   
$.sectionNumber.text        = args.sectionNumber;   
$.instructorLastName.text   = args.instructorLastname; 
$.courseTitle.text          = args.courseTitle;

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>