ace admin ajax load page, the solution to load the home page in a loop

ace admin 1.4

 

Loop loading occurs, mainly because the page cannot be found,

  

div that needs to be loaded by ajax

<div class="page-content-area" data-ajax-content="true">
	<!-- ajax content goes here -->
</div>

 

Modify ace-1.4.0\assets\js\src\ace.basics.js

var demo_ajax_options = {
	 'close_active': true,
	 
	 close_mobile_menu: '#sidebar',
	 close_dropdowns: true,
	 
	 'default_url': 'page/index',//default hash
	 'content_url': function(hash) {
		//***NOTE***
		//this is for Ace demo only, you should change it to return a valid URL
		//please refer to documentation for more info

		if( !hash.match(/^page\//) ) return false;
		var path = document.location.pathname;

		//for example in Ace HTML demo version we convert /ajax/index.html#page/gallery to > /ajax/content/gallery.html and load it
		if(path.match(/(\/ajax\/)(index\.html)?/))
			return path.replace(/(\/ajax\/)(index\.html)?/, '/ajax/content/'+hash.replace(/^page\//, '')+'.html') ;

		//for example in Ace PHP demo version we convert "ajax.php#page/dashboard" to "ajax.php?page=dashboard" and load it
		return path + "?" + hash.replace(/\//, "=");
	  }			  
}

 Modify it to your own logic

'default_url': '/welcome',

return contextPath + hash; (contextPath is preset)

		var demo_ajax_options = {
			 'close_active': true,
			 
			 close_mobile_menu: '#sidebar',
			 close_dropdowns: true,
			 
//			 'default_url': 'page/index',//default hash
			 'default_url': '/welcome',//default hash
			 'content_url': function(hash) {
//				//***NOTE***
//				//this is for Ace demo only, you should change it to return a valid URL
//				//please refer to documentation for more info
//
//				if( !hash.match(/^page\//) ) return false;
//				var path = document.location.pathname;
//
//				//for example in Ace HTML demo version we convert /ajax/index.html#page/gallery to > /ajax/content/gallery.html and load it
//				if(path.match(/(\/ajax\/)(index\.html)?/))
//					return path.replace(/(\/ajax\/)(index\.html)?/, '/ajax/content/'+hash.replace(/^page\//, '')+'.html') ;
//
//				//for example in Ace PHP demo version we convert "ajax.php#page/dashboard" to "ajax.php?page=dashboard" and load it
//				return path + "?" + hash.replace(/\//, "=");
				 if(hash==""){
					 if(window.Pace && Pace.running) Pace.stop();
					 $(this).ace_ajax('stopLoading', true);
				 }
				 return contextPath + hash;
			  }			  
		}

 

menu bar description

<a data-url="/welcome" href="#/welcome">
	<i class="menu-icon fa fa-tachometer"></i>
	<span class="menu-text"> Dashboard </span>
</a>

href is a link

data-url is highlighted when the current page address corresponds to it

 

refer to:

Ace Admin tutorial

https://www.cnblogs.com/LeeScofiled/p/6733625.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326269822&siteId=291194637