Search Results

Search found 2 results on 1 pages for 'crozzfire'.

Page 1/1 | 1 

  • Angularjs togglecheck error(not working as intended) with prechecked data

    - by crozzfire
    I have this plunker where i have a button that opens a bootstrap modal dialog box. I the modal, when a course is selected(checked) from this list, it adds 3 to the $scope.planned and also increases the progress bar accordingly. Similarly it also reduces in the same way when a checkbox is unchecked. This is the function that does the above: $scope.toggleCheck = function (course) { //debugger var x = $scope.checkcoursefunction($scope.selectedCourses, course); if(x==true){ $scope.selectedCourses.splice($scope.selectedCourses.indexOf(course), 1); $scope.planned -= 3; } else{ if ($scope.selectedCourses.indexOf(course) === -1){ $scope.selectedCourses.push(course); $scope.planned += 3; } else { $scope.selectedCourses.splice($scope.selectedCourses.indexOf(course), 1); $scope.planned -= 3; } } $scope.getPercentage(); }; I have 2 services from where the controller fetches its data named Requirements and Planned Services. The table in the modal has a list of the requirements service data. I also have a function named checkplanneddetails() that checks if an item from this data is present in the requirements data. If present, they come in the table pre-checked. This is the function that checks: $scope.checkplanneddetails = function(course){ $scope.coursedetail = course; $scope.requirementcoursename = ($scope.coursedetail.course.subject).concat("-",$scope.coursedetail.course.course_no); for(var k = 0; k < $scope.planneddetails.length; k++){ if($scope.requirementcoursename==$scope.planneddetails[k].course_name){ $scope.selectedCourses.push(course); return true; } } return false; }; $scope.checkcoursefunction = function(arr,obj){ return (arr.indexOf(obj) != -1); } This works fine with bringing the data as checked. But the togglecheck() function does not work as they are supposed to with these checked details(they work in reverse). It always returns true(for var x in togglecheck) even after the splice function. Am i splicing the course correctly?

    Read the article

  • Django shell command to change a value in json data

    - by crozzfire
    I am a django newbie and i was playing around in django's manage.py shell. Here is something i am trying in the shell: >>> data [{'primary_program': False, 'id': 3684}, {'primary_program': True, 'id': 3685}] >>> data[0] {'primary_program': False, 'id': 3684} >>> data[1] {'primary_program': True, 'id': 3685} >>> data[0].values() [False, 3684] >>> data[1].values() [True, 3685] >>> How should i give a command here to update the value of primary_program in data[1] to False and keep the rest of the json the same?

    Read the article

1