Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Using Ajax with Textpattern Articles
ajw-art wrote:
It was this one.
Thanks for the link. Haha, the person that said the code is “a bit convoluted” hit the mark :-) As alluded above, most of it was to get around the weird .load()
and script errors in IE in jQuery days gone by. The plugin could probably be about 5 lines of jQuery nowadays, but I don’t have the brains to unpick it and figure out why I did it the way I did…
If you need a hand with any other stuff on the page please let me know. Can’t promise I can help, but I’ll do what I can.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#14 2011-03-18 15:29:30
- qp2wd
- Member
- Registered: 2011-01-11
- Posts: 24
Re: Using Ajax with Textpattern Articles
Thanks! I actually worked out the major problems with the animation once I realized that I could store variables outside of a function if I didn’t want their values to be recalculated every time it executed. Magical!
The only problem I’m running into now is the Jquery.Cycle plugin flickering between captions from every image set that’s been pulled via ajax rather than just showing the caption for the currently displayed one. It’s probably got something to do with Jquery.Cycle being called multiple times as part of the smd_ajax success function, but I’m not sure how to tell Jquery.Cycle to wipe any captions it currently has stored when it’s called. I’ve tried .empty()
on the caption container and even .destroy()
on the cycle plugin itself; no luck. Hm, hm…
Last edited by qp2wd (2011-03-18 15:30:06)
Offline
Re: Using Ajax with Textpattern Articles
qp2wd wrote:
The only problem I’m running into now is the Jquery.Cycle plugin flickering between captions from every image set
Hmm, my guess (and it is a guess) is this is because the event that’s been attached to it on the previous load is being attached again on the next load… and the next… and the next, so that each time you load a page the event fires 3, 4, 5, 6… times. A good way to check this is in Firebug. Watch the caption element or one of the panes that shows you what’s going on in the event stack and load a page, then another. If you see a few things fire off per load then you know you’ve got an event issue.
If that is the case, you can either only attach them once on first page load and then call just the cycle ‘kickoff’ script each subsequent time, or you could try and cancel all events (I forget the name of the function) and reload them each time.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#16 2011-03-25 01:26:39
- ajw-art
- Member
- Registered: 2010-02-10
- Posts: 33
Re: Using Ajax with Textpattern Articles
If that is the case, you can either only attach them once on first page load and then call just the cycle ‘kickoff’ script each subsequent time, or you could try and cancel all events (I forget the name of the function) and reload them each time.
I get the gist of your statement, but I’m not sure how to implement it. Do you mean create a function that calls all the captions then cycles through them?
In the meantime, I’ve gone through a long (long) list of attempts to solve this rotating caption thing— I tried using event.stopPropagation
, various combinations of .die()
.unbind()
.remove()
and .destroy()
, and destroying the cycle plugin itself on each call to no avail. I’m sure I’m missing something obvious, but the project deadline is tomorrow so I’m tearing my hair out. This is exactly why I try and stick to the design side of things.
<!--calls jquery cycle after smd_ajax pulls in the content-->
function ajaxcycle(){
$('.caption').empty().remove();
$('#content article').append('<span class="caption"></span>');
$('#full-wrap').cycle('destroy').cycle({
before: onBefore
});
function onBefore() {
$('.caption')
.html('Opposite: ' + this.alt);
};
var cappy = $('.caption').html();
};
Offline
#17 2011-03-25 16:32:25
- qp2wd
- Member
- Registered: 2011-01-11
- Posts: 24
Re: Using Ajax with Textpattern Articles
Fixed it! Well, not exactly. I ended up using smd_gallery’s handy dandy {alt}
tag to create a psuedo-caption over the image. So it works in that the correct info now shows for each image, but I can’t position it in the same place that I wanted the caption in before since the div wrapping the cycled images has position:relative
. Ah well.
Offline
Re: Using Ajax with Textpattern Articles
Hi Stef,
I’m playing with your plugin which is great but it doesn’t really works for me as I need to keep the url’s and the backward button working… It could be great to make your plugin work with history, isn’t it?
Last edited by NicolasGraph (2013-07-04 14:37:47)
Offline
Re: Using Ajax with Textpattern Articles
NicolasGraph wrote:
It could be great to make your plugin work with history
It’s noted as a ToDo item in the code, yes. Integration with a jQuery history plugin should be feasible. Just need to find time to actually look into it.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Offline