Skip to content

Commit

Permalink
Better control over the Ajax-based page content refreshing.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmihajlovski committed May 18, 2016
1 parent 40cc917 commit 132f0e4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 3 additions & 2 deletions assets/angular/emit.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,15 @@ Rapidoid.initializer(function($scope) {

btn.append(' <i class="fa fa-refresh fa-spin"></i>');

$.post(window.location.href, inputs).done(function(data) {
var loc = Rapidoid.location || window.location.href;
$.post(loc, inputs).done(function(data) {

if (typeof data === 'string' || data instanceof String) {

if (go && data.indexOf('class="field-error"') < 0) {
Rapidoid.goAt(go);
} else {
$scope.ajaxBodyContent = data + '<!--' + reqId + '-->';
$scope[Rapidoid.holder] = data + '<!--' + reqId + '-->';
$scope.$apply();
}

Expand Down
11 changes: 10 additions & 1 deletion assets/rapidoid/rapidoid-extras.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ Rapidoid = (function() {
// rel="stylesheet">');
// }

var initialized = false;
function _init() {
if(initialized) {
return;
}
initialized = true;

$(function () {

$('[data-toggle="tooltip"]').tooltip();
Expand Down Expand Up @@ -120,6 +126,8 @@ Rapidoid = (function() {
}

function _initScope($scope) {
Rapidoid.scope = $scope;

for (var i = 0; i < scopeInitializers.length; i++) {
scopeInitializers[i]($scope);
}
Expand Down Expand Up @@ -178,7 +186,8 @@ Rapidoid = (function() {
createApp : createApp,
initializer : initializer,
plugin : plugin,
initApp : initApp
initApp : initApp,
holder: 'ajaxBodyContent'
};

})();
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 132f0e4

Please sign in to comment.