|
View:
New views
11 Messages
—
Rating Filter:
Alert me
|
| < Prev | 1 - 2 | Next > |
|
|
Re: How to avoid page refresh with jquery in typo3 ?yet you assumed that i did it on purpose ... wow
On Nov 6, 3:36 pm, Michel Belleville <michel.bellevi...@...> wrote: > Never mind Sam I had assumed that was not meant from you. > > Michel Belleville > > 2009/11/6 Sam Doyle <sammeh....@...> > > > Apologies. I believe I also called you michael. > |
|
|
Re: Re: How to avoid page refresh with jquery in typo3 ?chris wrote:
> <script> function loadAJAX() { > $(document).ready(function(){ > $("#ilink").load("http://mytypo3site.com/index.php? > id=20 .contentClass"); }); > }</script> > </head> > <body> <div id="ilink" onclick="loadAJAX();">xxx</div> </body> > </html> > > can i 'intercept' the current click in javascript or php somehow ? do > i have to code something into the setup/constant of my main typo3 page > template ? do i need to develop a custom extension ? do i need to use > the xajax/mootools/prototype extensions or can i get around this via > jquery ? 1) you don't need the loadAJAX() function, just straight $(document).ready(function(){}); is good enough 2) you can use advanced selectors to add events to all elements. So if your menu is <div id="menu">...</div>, you can use the following: $('div#menu a');, which will select all link elements in the div with id 'menu'. 3) then you'll want to add a click event to all those links: $('div#menu').click(function(){}); 4) you want jquery to load something after your click event, so you'll end up with this: $(document).ready(function(){ $('div#menu a').click(function(){ $('div#content').load($(this).attr('href')+' div#content'); return false; /*return false, because otherwise the link does its default action (load an url)*/ }); ); The above code is untested, and you'll probably need to fix stuff, but you should be well on your way now. Try to understand what each step of the code does. Pro tip: install the Firebug extension for Firefox to give you a better idea of what's going on while coding. Jonathan -- Jonathan Vanherpe - Tallieu & Tallieu NV - jonathan@... |
|
|
Re: Re: How to avoid page refresh with jquery in typo3 ?Jonathan Vanherpe (T & T NV) wrote:
> > 3) then you'll want to add a click event to all those links: > $('div#menu').click(function(){}); $('div#menu a').click(function(){}); //FTFY -- Jonathan Vanherpe - Tallieu & Tallieu NV - jonathan@... |
|
|
Re: Re: How to avoid page refresh with jquery in typo3 ?2009/11/6 chris <cs@...> i was tempted not to say anything anymore but Rick's comment
I don't think you repeated your question politely, that was one of the the points of my second reply. When you're asking something on the lines of "how do I get started using jQuery" you end up being answered "this is how you get started with jQuery". When you then reply something like "well thank you so very much for lecturing me on things I already know" and repeating the same vague question, expect the person that answered in the first place to ram the point home.
Well as Gerrit pointed, the quid pro quod lied in the way the question was asked and the place where it was asked. Would you have asked the way you just did here my answer would have been quite different, a lot more to the point, a lot less sarcastic and a whole lot more useful, probably something like what Jonathan posted. So I don't want to hammer my points anymore than I've already done, nor do I enjoy a flamewar. I can see now we both started on the wrong foot, vague questions got vague answers, and the rest was escalation. I'm sorry if I hurt your feelings, and I'm sure you didn't mean to be rude too in the first place. Michel Belleville P.S. : For the surname thing, come on, considering how the thread went in flames you can understand I was more than a little pissed at that point, you were too. Plus I didn't take it that bad in the first place, and I just wanted to reassure Sam, not to imply I thought you meant to insult me. |
|
|
Re: Re: How to avoid page refresh with jquery in typo3 ?Hey Rick,
I've taken the point for my reply in this other discussion, and I admit the attitude there wasn't attuned to the situation. My bad. Here's another situation altogether. I hope you won't mind me skipping the psychoanalysis too, because I hardly think I'm being abusive as a rule, and I guess in our line of work most of us get patronized every now and then (and that's what I meant by "fair share", I may have misused that expression if in this context it can't mean "the share anyone in my line of works normally receives") and even if that may hurt one's pride for a second if one takes the time to listen to the content one might stumble upon the solution to the problem one's been asking about in the first place. That was the point of my argumentation here, not to pretend I've been badly abused and would like a hug. And even though I don't enjoy the feeling of being patronized, I often enjoyed the resulting knowledge and even go as far as thanking the "patronizer" after I've got the point. So I've taken the point and will try to be nicer (in fact if you riffle through mails I've posted *before I've been flamed by Chris* you may notice I'm one to reply to newbie questions and usually pointing to the right page of the documentation to help the person go further when it helps). Michel Belleville 2009/11/6 Rick Faircloth <Rick@...>
|
|
|
Re: How to avoid page refresh with jquery in typo3 ?Jonathan: THANKS SO MUCH ... with your simple, short and polite help i
have now asynchronous page loads up and running in typo3 ... it's a thing of beauty :) i have a small issue with menu highlighting and my sub menus not appearing anymore when i load a page with subs but i know how to solve this (i think). will post the full solution once the little issues are solved ... Michel: get some help ! |
|
|
Re: Re: How to avoid page refresh with jquery in typo3 ?chris wrote:
> Jonathan: THANKS SO MUCH ... with your simple, short and polite help i > have now asynchronous page loads up and running in typo3 ... it's a > thing of beauty :) i have a small issue with menu highlighting and my > sub menus not appearing anymore when i load a page with subs but i > know how to solve this (i think). will post the full solution once the > little issues are solved ... I guess you'll just need to add this: $('div#menu').load($(this).attr('href')+' div#menu'); But I should warn you, this is far from efficient, as you're making 2 requests for the same page this way, instead of the one request it would take to just load the page normally. I personally think it's just not worth the effort, but I've told you that before. > Michel: get some help ! please just stop flaming each other so this thread can die/turn into a useful thread, both of you. It's easy to do: if you feel you need to respond to a flame, type your response, then instead of clicking send, click the close button. Jonathan -- Jonathan Vanherpe - Tallieu & Tallieu NV - jonathan@... |
|
|
RE: Re: How to avoid page refresh with jquery in typo3 ?Thanks, Michel…a good start. As far as “thanking” someone who has belittled you, I’m sure you
wouldn’t have minded a chance to get in a good punch to properly “thank them” for their help, even
while “enjoying the resulting knowledge”. Rick From: Michel Belleville
[mailto:michel.belleville@...] Hey Rick, 2009/11/6 Rick Faircloth <Rick@...> Michel commented: “I get patronized my fait share
in my job, and sometimes I feel bad about it” Now we know the root of your attitude
problem. The first step in your recovery as an
abusive person is to understand that you are doing the same to others here
(thankfully, you haven’t been on the very long as far as I can tell or you would have
helped destroy it) as others do to you at work, and to understand how that makes you
feel: “I feel bad about it”… I don’t think you enjoy how others at
your place of employment make you feel, so realize that your remarks make others
on this list feel exactly as you do when mistreated by your co-workers. You would do *very* well to start
trying to “treat others as you would like to be treated.” Assistance on the list, if it has to be
dished up with bad attitude, isn’t welcome. Rick From: Michel
Belleville [mailto:michel.belleville@...]
Hey
Gerrit, 2009/11/6
Gerrit Kuilder <gerrit.undefined@...> Hi
Michel,
2009/11/6
Gerrit Kuilder <gerrit.undefined@...> Hi
Chris,
Michel
Belleville |
|
|
Re: Re: How to avoid page refresh with jquery in typo3 ?Chris,
With all the flaming on this topic, nobody even bothered to provide the simple answer; load load makes an ajax call and returns the results to an element. If you have a div with an ID of 'myData'' $("#myData").load (theURL) will perform an ajax call to 'theURL' and place the contents into 'myData'. google 'jquery load tutorial' for more info. this will allow you to load a part of a page with data without refreshing the whole page. Now for the soapbox: It is incredibly saddening to watch someone ask for help and get the kind of responses you've gotten on this topic. It's a recurring theme; Someone is in the water drowning and all you get are people suggesting that you should learn to swim and are happily watching you drown instead of pulling you out of the water.It's just plain sick. Let me apologize. It does NOT represent the vast majority of programmers out there. Climbing down off te soapbox. I hope this was of help to you. It is hard finding good examples sometimes and not everyone has the luxury of an expert nearby when they need them. Michel Belleville wrote: > Hey Rick, > > I've taken the point for my reply in this other discussion, and I > admit the attitude there wasn't attuned to the situation. My bad. > > Here's another situation altogether. > > I hope you won't mind me skipping the psychoanalysis too, because I > hardly think I'm being abusive as a rule, and I guess in our line of > work most of us get patronized every now and then (and that's what I > meant by "fair share", I may have misused that expression if in this > context it can't mean "the share anyone in my line of works normally > receives") and even if that may hurt one's pride for a second if one > takes the time to listen to the content one might stumble upon the > solution to the problem one's been asking about in the first place. > That was the point of my argumentation here, not to pretend I've been > badly abused and would like a hug. And even though I don't enjoy the > feeling of being patronized, I often enjoyed the resulting knowledge > and even go as far as thanking the "patronizer" after I've got the point. > > So I've taken the point and will try to be nicer (in fact if you > riffle through mails I've posted *before I've been flamed by Chris* > you may notice I'm one to reply to newbie questions and usually > pointing to the right page of the documentation to help the person go > further when it helps). > > Michel Belleville > > > 2009/11/6 Rick Faircloth <Rick@... > <mailto:Rick@...>> > > Michel commented: > > > > “I get patronized my fait share in my job, and sometimes I feel > bad about it” > > > > Now we know the root of your attitude problem. > > > > The first step in your recovery as an abusive person is to > understand that you > > are doing the same to others here (thankfully, you haven’t been on > the very long > > as far as I can tell or you would have helped destroy it) as > others do to you at work, > > and to understand how that makes you feel: “I feel bad about it”… > > > > I don’t think you enjoy how others at your place of employment > make you feel, > > so realize that your remarks make others on this list feel exactly > as you do when > > mistreated by your co-workers. > > > > You would do **very** well to start trying to “treat others as you > would like to be treated.” > > > > Assistance on the list, if it has to be dished up with bad > attitude, isn’t welcome. > > > > Rick > > > > > > *From:* Michel Belleville [mailto:michel.belleville@... > <mailto:michel.belleville@...>] > *Sent:* Friday, November 06, 2009 8:50 AM > *To:* jquery-en@... <mailto:jquery-en@...> > *Subject:* Re: [jQuery] Re: How to avoid page refresh with jquery > in typo3 ? > > > > Hey Gerrit, > > I get what you're saying, and I basically agree with you that you > don't need to be an engineer to do a bit of hacking (I merely > pointed to documentation that would have taken him two hours top > investigating, I hardly call that becoming an engineer even in a > field as small as jQuery), and that asking the question right is > important. I also agree that someone asking you a question should > respect you, if not out of regards to your knowledge and skills, > at the very least because you've spend time to actually read and > write down an answer to his question, even though you feel > patronized by the answer (and who wouldn't feel patronized when he > gets and answer that basically says : here's what you should do). > > That's not what my answer is about. > > I get patronized my fait share in my job, and sometimes I feel bad > about it, especially when the patronizer is right, and that's > because it almost invariably happens when I didn't do the job in > the first place. So in that case, the first thing I do is ask > myself "what if I did what the guy tells me ?". Typically I then > do that, and usually it just works, and I feel better afterwards. > What I try to never do when I feel patronized is insult the person > that just made me feel that way, for two reasons. First because > sometimes the patronizer is right, and I'll act like a fool or a > hypocrite trying to argue the point beyond being proven wrong. > Second because whining won't help me anyway. > > So Chris, when you ask the question wrong to the wrong people, at > least don't get surprised to be patronized, especially since if > your real desire is to have all the "nitty gritty" put out of the > way by someone else. If you want to be allowed to whine when > things don't work, either whine to yourself or pay someone to be > whined on (that usually works well in the software industry > provided you've got money to spare). > > Then again Gerrit, I didn't feel insulted by you, you've been > quite decent and tactful and I respect you for that, plus I concur > that using a plugin that does just what you need is fine, provided > said plugin exists. > > I also guess that this has gotten into something nasty, and > neither was that my intention (though I'm not afraid to get into > nasty territory once in a while when I cross answers displaying > the attitude Chris gratified us with earlier ; when asses needs to > be kicked don't mind me if I get my boots on), but you're not to > blame in any way here. > > Michel Belleville > > 2009/11/6 Gerrit Kuilder <gerrit.undefined@... > <mailto:gerrit.undefined@...>> > > Hi Michel, > > In another email I already said that asking the right question > will make it easier to get the right question. > > So if Chris had asked for the right screwdriver to replace a > window the answer might have been different, it would have shown > that Chris knew enough about engineering that he needed a > screwdriver. He just wanted to be pointed to the right one by the > engineers, because sometimes all you need is to replace a window > and you don't need to know how to build a whole house. He (and I) > just need another window to fit with the interior where he wants > (or needs) to spend his precious time on. > > I have been using jquery plugins because I need to get a job done, > I need to spend my time on that job. > > I have been doing a fair bit of programming in various languages > and have been using 'plugins' (Pm's, classes, jquery plugins) to > avoid spending/wasting time on some nitty gritty details. I need > to spend/waste time on other nitty gritty details and the sooner I > get to the required end result the better. > > That means I have been using/abusing other people's knowledge and > skills, so I have time to acquire knowledge and skills that can be > used/abused by other people. > > Please don't see this as disrespect for you or your knowledge and > skills. > I actually respect the K and S, using a plugin makes sure that I > get the best and right tools and don't use something full of my > own errors. > I came to this mailinglist because of a problem I have with a > plugin (or 2), and the developer(s) ask on their websites to post > questions here. > > I also think this gets into something nasty, this was not my > intention at all. If I offended you it was unintentionally and in > that case I apologize. > > Regards, > > Gerrit > > > On 11/06/2009 12:21 PM, Michel Belleville wrote: > > 2009/11/6 Gerrit Kuilder <gerrit.undefined@... > <mailto:gerrit.undefined@...>> > > Hi Chris, > > I understand your frustration, it is like asking how to replace a > window and being told to become an engineer first. > > > You don't need to become an engineer before you're changing a > window, but if you don't know how to use a screwdriver and where > to get a spare window I guess you should start there anyway, it > won't take as much time as to get an engineer's degree I assure > you. It may very well be frustrating to start with the little > wheels on a little country road before you're trying to bike your > way through a car crowded city on rush hour, but still my advice > is to start with the little wheels and the little country road. > > > I also am a mere consumer of jquery and have been frustrated > by finding the right stuff, trying to get it to work and > finding out later that the results are not what I was looking for. > Especially the lack of a very basic sample that shows the code > working can be a nightmare, you can waste hours. > > > Consider this : how better is it to "waste" (I'd rather write > "spend") a few hours learning the basics then work your way up to > the solutions more easily and confidently because you at least > know what it's about, rather than "spend" (and here I really mean > "waste") the same amount of hours googling over-specific wild > goose chases or banging your head on your keyboard repeatedly > because what you've found and tried does not in fact do anything > close to what you wanted in the first place ? > > I know I'd rather "waste" my time doing the tutorials, but it's up > to you. And there's no lack of very basic sample, you're just not > looking for a very basic sample here, you're looking for a > readymade solution. When you're not finding a readymade solution, > you can either develop your own (which requires knowing the tools > if not the trade) or buy someone's time to work it up for you, or > let it go and do something else entirely until someone has had the > same problem and developped a solution for you, but it may be some > time before that happens. > > Off my soapbox onto your issue: > Taconite http://jquery.malsup.com/taconite/ might do what you > want to do: reloading/replacing parts of a page without the > need to load the whole page, this comes with good examples and > documentation. > > One thing you have to be aware off is that the data passed > back to the page has to be XML/XHTML, opening the link in a > new window in firefox is a good way to check if this is the > case, and you should use utf8 , so no but the utf > version of it (I hope you don't mind one more Google for that > ;-) ) > > > This might be an interesting solution to some problems, though > it'll require learning taconite's syntax as well as basic jQuery > to get the hooks on the app. So getting started with jQuery will > still be a good idea. > > > > Michel Belleville > > > > > > |
|
|
Re: How to avoid page refresh with jquery in typo3 ?On Nov 6, 5:25 pm, "Jonathan Vanherpe (T & T NV)" <jonat...@...>
wrote: > I guess you'll just need to add this: > $('div#menu').load($(this).attr('href')+' div#menu'); > > But I should warn you, this is far from efficient, as you're making 2 > requests for the same page this way, instead of the one request it would > take to just load the page normally. > > I personally think it's just not worth the effort, but I've told you > that before. yes i figured that out, also solved the menu highlighting which was just a CSS div order error on my part. this is how it works for the moment: <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(document).ready(function(){ $('#menu a').click(function(){ $('#maincontent').load($(this).attr('href')+' #maincontent'); $('.submenu').load($(this).attr('href')+' .submenu'); return false; }); }); </script> in Safari on the mac it works, the pages load and the submenu loads, however there is a problem with the submenu. on the first click of a submenu item the page loads/refreshes completely but then when i click on another submenu item it loads correcrly directly into the div without refresh, and then alternately, once it loads into the div, once it refreshes the whole page .. in Firefox on the mac the first level menu and loading works but the submenu doesn't appear In Internet Explorer 8 the first level works 'sort of' on some clicks it loads a page corrctly and on other clicks it doesn't load at all, but it's random, i did a series of 10 clicks several times in a row after cleaning cache each time and everytime it works/doesn't on some other combination of pages ... after a dozen clicks or so it doesn't load anything at all anymore ... in terms of efficiency and not being worth the effort, could you elaborate your thoughts on this. the actual page content i am loading through those calls is only very short text paragraphs (maincontent) and a 4 item list (submenu). i have three columns: menu | content | flash the flash movie is an interactive slideshow which is running continuously while the user browses the site ... i want this slideshow to run continously and if i work with refresh/reload the slideshow/ movie always starts from the beginning ... but i want the user to be able to browse both parts of the site (the html menu/content and the flash movie) independently without one interfering with the other .. for some other reasons i cannot use frames which would solve this problem and give me independent navigation so i thought my solution would be more efficient than a traditional refresh can you explain why i got it wrong ? for this site i don't need bookmarking/history or back button browser functionality ... thx again for the help ! |
|
|
Re: Re: How to avoid page refresh with jquery in typo3 ?chris wrote:
> On Nov 6, 5:25 pm, "Jonathan Vanherpe (T& T NV)"<jonat...@...> > wrote: >> I guess you'll just need to add this: >> $('div#menu').load($(this).attr('href')+' div#menu'); >> >> But I should warn you, this is far from efficient, as you're making 2 >> requests for the same page this way, instead of the one request it would >> take to just load the page normally. >> >> I personally think it's just not worth the effort, but I've told you >> that before. > > yes i figured that out, also solved the menu highlighting which was > just a CSS div order error on my part. this is how it works for the > moment: > > <script src="http://code.jquery.com/jquery-latest.js"></script> > <script> > $(document).ready(function(){ > $('#menu a').click(function(){ > $('#maincontent').load($(this).attr('href')+' > #maincontent'); > $('.submenu').load($(this).attr('href')+' .submenu'); > return false; > }); > }); > </script> > > in Safari on the mac it works, the pages load and the submenu loads, > however there is a problem with the submenu. on the first click of a > submenu item the page loads/refreshes completely but then when i click > on another submenu item it loads correcrly directly into the div > without refresh, and then alternately, once it loads into the div, > once it refreshes the whole page .. > > in Firefox on the mac the first level menu and loading works but the > submenu doesn't appear > > In Internet Explorer 8 the first level works 'sort of' on some clicks > it loads a page corrctly and on other clicks it doesn't load at all, > but it's random, i did a series of 10 clicks several times in a row > after cleaning cache each time and everytime it works/doesn't on some > other combination of pages ... after a dozen clicks or so it doesn't > load anything at all anymore ... Do you have a link we can see this at? > in terms of efficiency and not being worth the effort, could you > elaborate your thoughts on this. the actual page content i am loading > through those calls is only very short text paragraphs (maincontent) > and a 4 item list (submenu). i have three columns: [snip] > so i thought my solution would be more efficient than a traditional > refresh can you explain why i got it wrong ? for this site i don't > need bookmarking/history or back button browser functionality ... Well, even though you're only showing part of the page, the whole page gets downloaded by your browser (twice, since you're calling load() twice). jQuery will download the whole page, then parse it, throw away what is doesn't need, and insert the small chunk you wanted into the page. Basically this is slower then just loading the page straight away (but I guess you don't see the flicker that's associated with a page load). > thx again for the help ! > Jonathan -- Jonathan Vanherpe - Tallieu & Tallieu NV - jonathan@... |
| < Prev | 1 - 2 | Next > |
| Free embeddable forum powered by Nabble | Forum Help |