arvgta/ajaxify

option for class based selector

Closed this issue · 9 comments

right now its only possible to make it work with id selector, can it be possible to add support for classes?
so instead of:

jQuery('#content').ajaxify();

we will be able to do:

jQuery('.content').ajaxify();

Please excuse the heavy delay and thanks for the interesting issue!

I agree it would be awesome to add support for specifiying content to be swapped by a class additionally, or for the matter any kind of jQuery selection, which is not supported at the moment...

Have you tested it against your use-case yet?

If you're willing to test I would try to make the change in code...

I am very willing to test, I tried to make the change myself but I couldn't get it.
thanks a lot

Thanks for posting back so quickly!
It may take a while, because I'm busy right now, but I will most definitely give it a try.

Please hold on, and I'll get back to the matter in a couple of days.

Thanks again for the great idea and your willingness to test...

Hi again,

please also see this thread in the jQuery forum

Just to make sure, we're talking about the same code fragment - here is where I think the change should be made. If you feel like it, you could try changing it yourself:

    lDivs: function ($t) { //load target selections into DOM
        if ($.cache1()) $t.each(function() { //iterate through elements
            _ld($(this), $.cache1().find("#" + $(this).attr("id"))); //load target element into DOM
        });
    }

One can clearly see, that only elements with an ID are processed...
I think the above code has to be abstracted somehow, maybe to something like this:

    lElements: function ($t) { //load target selection into DOM
        if ($.cache1()) $t.each(function() { //iterate through elements
            _ld($(this), $.cache1().find(this)); //load single target element into DOM
        });
    }

as recommended in that thread in the jQuery forum

or

    lElements: function ($t) { //load target selection into DOM
        if ($.cache1()) $t.each(function() { //iterate through elements
            _ld($(this), $.cache1().find($(this))); //load single target element into DOM
        });
    }

(just tested the second and third, above code snippets - they don't work straight away unfortunately)

So, what we need really is the following code:

    lElements: function ($t) { //load target selection into DOM
        if ($.cache1()) $t.each(function() { //iterate through elements
            _ld($(this), $.cache1().find(xy)); //load single target element into DOM
        });
    }

...where "xy" is a selector for the corresponding target element in $.cache1()

Feel free to fiddle around a bit yourself!

Would you like me to refresh this thread in the jQuery forum?

@boynet How's it going? Should we keep this issue alive or close it?

Ajaxify is meant to only change the 1 main "content" area.

jQuery('.content').ajaxify(); implies that Ajaxify will be applied to each element with a class of "content". Classes in html implies that there is or could be more than one element with that class.

I think it would be easy enough to understand and use if Ajaxify works with this code:

jQuery('.content').first().ajaxify();

Hi Thinsoldier!

Thanks very much for your contribution!
As mentioned before, I would agree that the idea of this issue would be great, i.e. to supply a class instead of IDs, or even support any jQuery selection.

Unfortunately, I never got it to work properly.

Specifying the main content ID explicitly is possible with the maincontent parameter.
Please see Setting maincontent

So that's not the problem. The problem is, that I can't get the swapping of elements to work.

@boynet : It would be great if you could indicate, whether you got it working or not?

If several divs should be swapped, just specify their IDs like this:
jQuery('#content, #nav').ajaxify();

Ah, yes, that probably does disqualify my idea.

Thanks!

I would not say, it completely disqualifies both of your ideas.
Just different approaches.

Your approach(es) would be more powerful, but I can't seem to get it to work.
My current approach works, but is less powerful...