Hi drupal community,

i'm making my site, working with ajax.

i use the following code, which i inject with the module "JS injector", to implement this:

Drupal.behaviors.my_ajax = function(context) {
	$('#content-group-inner a').live('click',function(e) {
        var url = $(this).attr('href');
        //$('#content-region-inner').slideUp('slow');
$('#content-region-inner').empty().html('<img src="ajax-loader.gif" style="margin-left:50%;"/>');
        $('#content-region-inner').load(url+" #content-region-inner", function(){
            $('#content-region-inner').slideDown('200');
        });
        return false;
});
};

This is working great, but on some content, or forms, the JS seems to be disabled. But it isn't, i can also see, that the js scripts are loaded in the head.
In another case, like in forum, my Css isn't fully applied to the site, so my layout seems to be a little bit broken.
I was reading about the "Load ajax" module, but using this module causes my layout to break even more.
So can someone tell me how to solve my prob, or give me some suggestions on how the way could be to solve this issue.
Every help and suggestion is appreciated.
Thanx a lot for your support.

dennis605

Comments

dennis605’s picture

Doesn't anybody have got an idea, on how to help me, getting this working?

dennis605’s picture

Doesn't anybody knows some part of solution?
I was searching almost the whole forum for my topic.
It seems, that many others are having the same problem not limited to a certain module.
But unfortunately i didn't find any solution.
Wouldn't it be great to solve this?
Why do we not speak together about this?
Every help is appreciated.
Please.

williamW’s picture

Where exactly are you injecting your code. Is it in a node, block, panel, custom moduel, If we knew more we might be able to help.
But I would suggest is to use the default drupal functions to add js to the site.
Do some research on the drupal_add_js() function, this is what we use to add all our custom js code. I've used the module to inject js but it did not seem to work satisfactory for me either.

dennis605’s picture

Hi williamW,

thanx for your reply .I didn't know, that i put to less information in my post.

In the meanwhile in fact i wrote a module to inject the the code.
But i think it maybe doesn't matter. Here is the code i tried to implement it.
my_ajax.module:

<?php
function my_ajax_init() {
drupal_add_js(drupal_get_path('module', 'my_ajax') .'/my_ajax.js');
}

my_ajax.js:

Drupal.behaviors.my_ajax = function (context) {
    $('#content-group-inner a').live('click', function (e) {
        var url = $(this).attr('href');
        //$('#content-region-inner').slideUp('slow');
        $('#content-region-inner').empty().html('<img src="ajax-loader.gif" style="margin-left:50%;"/>');



        $('#content-region-inner').load(url + " #content-region-inner", function () {
            

            $('#content-region-inner').slideDown('200');
        });
        Drupal.attachBehaviors('#content-region-inner');
        return false;
    });
};

But the result is the same issue i mentioned above.
Please let me know, if you need more informations.
I do not think, that so less code will get this working, but what else do i have to do?
I really need help in that.
Hope you have some suggestions.
You do not need to have the complete solution, but some tips maybe, would helping me.