Hi, I have managed to create a simple script.js for my theme containing the following code.
$(document).ready( function() {
var init_links = function() {
$('body')
.find('a')
.click(function () {
var linktothis = $(this).attr('href')+" #content-inner-inner";
$('#content-inner-bg').slideUp("slow", function(){
$(this).empty().load(linktothis, init_content_links_1).slideDown("slow");
});
return false
});
};
var init_content_links_1 = function() {
$('#content-inner')
.find('a')
.click(function () {
var linktothis = $(this).attr('href')+" #content-inner-inner";
$('#content-inner-bg').slideUp("slow", function(){
$(this).empty().load(linktothis, init_content_links_2).slideDown("slow");
});
return false
});
};
var init_content_links_2 = function() {
$('#content-inner')
.find('a')
.click(function () {
var linktothis = $(this).attr('href')+" #content-inner-inner";
$('#content-inner-bg').slideUp("slow", function(){
$(this).empty().load(linktothis, init_content_links_1).slideDown("slow");
});
return false
});
};
$(init_links);
});
I have placed this in my theme directory and it works really well! The only problem is that the "login" submit button and other form buttons such as "save" on a content creation page don't actually post any information. The first function in the script above searches the whole body of the first loaded html page (when you arrive on the site) for "a" tags (links) and then creates an onClick function for all of those links which loads the url request via AJAX and doesn't return. It then gets the content of the request div id (#content-inner-inner) and places it in the current content container div (#content-inner-bg) and then it looks for all links within that div and does the same as the above using the second and the third functions respectively after each content refresh. I will obviously be modifying this code so the the submit buttons within forms are filtered out but what I can't get my head around is quite simply creating js code to submit someone logging in. I am guessing that once they have clicked the login button it will send the necessary requests to validate the user login and will then request the URL once the user login info has been confirmed. I will be sending that URL request via AJAX in a function once the login has succeeded and will update the relevant divs in my theme to reflect the user status.
If that doesn't make any sense at all please don't hesitate to contact me for details on my theme and how my script works or if you can't be bothered... can you please explain me if it is possible that, by using AJAX Load, I can create an AJAX user login?
Comments
Comment #1
nedjoAjax load is only for the problem of loading additional javascript and css files along with an AJAX transaction.
See http://drupal.org/project/ajaxsubmit and http://drupal.org/project/ajax for usages like what you're doing.