2
How can I develop a SPA with jQuery? I did with Angularjs with the following code, but I’m having difficulties to migrate to it definitively and decided to stick with jQuery not to be late.
var myapp = angular.module('myapp', []);
myapp.config(function($routeProvider) {
$routeProvider
.when('/:acess', {
templateUrl : 'sources/default.html',
controller : 'myapp-controll'
})
.otherwise({ redirectTo: '/welcome' });
});
myapp.controller('myapp-controll', function($scope, $routeParams) {
$scope.templateUrl = './g_c.php?a='+$routeParams.acess;
});
This code carried my pages without leaving the original page, using #
Explaining better:
Let’s pretend there’s a file that way:
./pages/ (pasta) ----
index.html (este) |
--/> home.html
|
--/> produtos.html
By clicking on Pagina inicial
he has to click on the div "content" all the contents of the requested file, ie he would have to take only the home
and pull him out of the briefcase pages
playing all the content in the div and loading it completely.
But what? If I want to share the link, I will have to teach the user how to check up to it? Which buttons to click? This would cause the site to lose many users and access, so the answer is no!
Or Whether I provided the link http://meusite/#/produtos/
for someone, when accessing it has to click on the div "content" the content of the page produtos
automatically, without having to click anything.
<div id="inicio"><a href="#/home/">Pagina inicial</a> | <a href="#/produtos/">Produtos</a> | </div>
<div id="conteudo">Oi, eu sou a pagina inicial</div>
What language is on the server side?
– Sergio
Use PHP to handle my data on the server.
– Vinícius Lara
It’s late for me (European zone). I deleted my answer because it was clear after your last explanation that you need to use the
.load()
. I will add your info to the question. I begin to wonder if it would not be better to use Angular itself and learn better how it works?– Sergio
Angular is complicated for me, I would even learn but the time is short. Wouldn’t it be possible what I explained in jQuery? @Sergio
– Vinícius Lara