Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix to getTemplate(), $http instead of $.ajax() #347

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions build/ng-grid.debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* ng-grid JavaScript Library
* Authors: https://github.com/angular-ui/ng-grid/blob/master/README.md
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
* Compiled At: 04/10/2013 18:25
* Compiled At: 04/17/2013 15:36
***********************************************/
(function(window, $) {
'use strict';
Expand Down Expand Up @@ -1196,7 +1196,7 @@ var ngFooter = function ($scope, grid) {
/// <reference path="footer.js" />
/// <reference path="../services/SortService.js" />
/// <reference path="../../lib/jquery-1.8.2.min" />
var ngGrid = function ($scope, options, sortService, domUtilityService, $filter, $templateCache, $utils, $timeout, $parse) {
var ngGrid = function ($scope, options, sortService, domUtilityService, $filter, $templateCache, $utils, $timeout, $parse, $http) {
var defaults = {
//Define an aggregate template to customize the rows when grouped. See github wiki for more details.
aggregateTemplate: undefined,
Expand Down Expand Up @@ -1417,11 +1417,17 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
var t = self.config[key];
var uKey = self.gridId + key + ".html";
if (t && !TEMPLATE_REGEXP.test(t)) {
$templateCache.put(uKey, $.ajax({
type: "GET",
url: t,
async: false
}).responseText);
$http.get(t, {
cache: $templateCache
})
.success(function(data){
$templateCache.put(uKey, data);
});
// $templateCache.put(uKey, $.ajax({
// type: "GET",
// url: t,
// async: false
// }).responseText);
} else if (t) {
$templateCache.put(uKey, t);
} else {
Expand Down Expand Up @@ -2795,7 +2801,7 @@ ngGridDirectives.directive('ngGridMenu', ['$compile', '$templateCache', function
};
return ngGridMenu;
}]);
ngGridDirectives.directive('ngGrid', ['$compile', '$filter', '$templateCache', '$sortService', '$domUtilityService', '$utilityService', '$timeout', '$parse', function ($compile, $filter, $templateCache, sortService, domUtilityService, $utils, $timeout, $parse) {
ngGridDirectives.directive('ngGrid', ['$compile', '$filter', '$templateCache', '$sortService', '$domUtilityService', '$utilityService', '$timeout', '$parse', '$http', function ($compile, $filter, $templateCache, sortService, domUtilityService, $utils, $timeout, $parse, $http) {
var ngGridDirective = {
scope: true,
compile: function() {
Expand All @@ -2804,7 +2810,7 @@ ngGridDirectives.directive('ngGrid', ['$compile', '$filter', '$templateCache', '
var $element = $(iElement);
var options = $scope.$eval(iAttrs.ngGrid);
options.gridDim = new ngDimension({ outerHeight: $($element).height(), outerWidth: $($element).width() });
var grid = new ngGrid($scope, options, sortService, domUtilityService, $filter, $templateCache, $utils, $timeout, $parse);
var grid = new ngGrid($scope, options, sortService, domUtilityService, $filter, $templateCache, $utils, $timeout, $parse, $http);

// if columndefs are a string of a property ont he scope watch for changes and rebuild columns.
if (typeof options.columnDefs == "string") {
Expand Down
18 changes: 12 additions & 6 deletions src/classes/grid.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference path="footer.js" />
/// <reference path="../services/SortService.js" />
/// <reference path="../../lib/jquery-1.8.2.min" />
var ngGrid = function ($scope, options, sortService, domUtilityService, $filter, $templateCache, $utils, $timeout, $parse) {
var ngGrid = function ($scope, options, sortService, domUtilityService, $filter, $templateCache, $utils, $timeout, $parse, $http) {
var defaults = {
//Define an aggregate template to customize the rows when grouped. See github wiki for more details.
aggregateTemplate: undefined,
Expand Down Expand Up @@ -222,11 +222,17 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
var t = self.config[key];
var uKey = self.gridId + key + ".html";
if (t && !TEMPLATE_REGEXP.test(t)) {
$templateCache.put(uKey, $.ajax({
type: "GET",
url: t,
async: false
}).responseText);
$http.get(t, {
cache: $templateCache
})
.success(function(data){
$templateCache.put(uKey, data);
});
// $templateCache.put(uKey, $.ajax({
// type: "GET",
// url: t,
// async: false
// }).responseText);
} else if (t) {
$templateCache.put(uKey, t);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/directives/ng-grid.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ngGridDirectives.directive('ngGrid', ['$compile', '$filter', '$templateCache', '$sortService', '$domUtilityService', '$utilityService', '$timeout', '$parse', function ($compile, $filter, $templateCache, sortService, domUtilityService, $utils, $timeout, $parse) {
ngGridDirectives.directive('ngGrid', ['$compile', '$filter', '$templateCache', '$sortService', '$domUtilityService', '$utilityService', '$timeout', '$parse', '$http', function ($compile, $filter, $templateCache, sortService, domUtilityService, $utils, $timeout, $parse, $http) {
var ngGridDirective = {
scope: true,
compile: function() {
Expand All @@ -7,7 +7,7 @@
var $element = $(iElement);
var options = $scope.$eval(iAttrs.ngGrid);
options.gridDim = new ngDimension({ outerHeight: $($element).height(), outerWidth: $($element).width() });
var grid = new ngGrid($scope, options, sortService, domUtilityService, $filter, $templateCache, $utils, $timeout, $parse);
var grid = new ngGrid($scope, options, sortService, domUtilityService, $filter, $templateCache, $utils, $timeout, $parse, $http);

// if columndefs are a string of a property ont he scope watch for changes and rebuild columns.
if (typeof options.columnDefs == "string") {
Expand Down