|
[Solved] Load tips from external file... how?
|
|
4th January, 20:00
(This post was last modified: 4th January 20:01 by sparky672.)
Post: #1
|
|||
|
|||
|
[Solved] Load tips from external file... how?
Why am I finding this so difficult? I cannot locate a working example and I can't seem to figure out how to piece this together from the online documentation.
This is something I'd expect to see as a secondary default setup but I must be blind. My tooltips are going to be way too long to embed inside all the "title" attributes. So I was thinking I'd simply store these in an external file and call them up as needed. Despite my best efforts, no matter how I try to call this file, nothing happens. Can somebody point me to a working example? Thank-you! |
|||
|
4th January, 21:15
Post: #2
|
|||
|
|||
|
RE: Load tips from external file... how?
Update:
I finally figured out how to load the content of an external HTML file but I have absolutely no idea how to parse it! With one working example or demo, it's probably a snap... however I can't seem to find the forest through the trees. |
|||
|
5th January, 16:23
Post: #3
|
|||
|
|||
|
RE: Load tips from external file... how?
Hmm sparky, not sure if this is quite what you're looking for but why not include the tip contents under a standard div class directly next to all your elements that need a tooltip? Like so:
HTML Code
JS Code
Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
5th January, 16:32
(This post was last modified: 5th January 16:34 by sparky672.)
Post: #4
|
|||
|
|||
RE: Load tips from external file... how?
(5th January 16:23)Craig Wrote: Hey sparky, it's just a case of using the dataFilter function and/or success handler: Thank-you for the reply but I'm still confused by the example. ![]() In my remote file, I have this... JS Code
Then in the HTML of the page using qTips... <ul> <li><a href="#" title="one">My Link to Tip 1</a></li> <li><a href="#" title="two">My Link to Tip 2</a></li> <li><a href="#" title="three">My Link to Tip 3</a></li> <li><a href="#" title="four">My Link to Tip 4</a></li> </ul> Now I'm totally lost. How does the "content.replace" work?... I cannot seem to understand how to apply that line in your example to my situation. I'm sure I'll feel stupid after you explain it... Thank-you for all your hard work on qTip! |
|||
|
5th January, 16:49
Post: #5
|
|||
|
|||
|
RE: [Solved] Load tips from external file... how?
Oh I see. You could do something along the lines of this:
JS Code
Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
5th January, 16:57
Post: #6
|
|||
|
|||
|
RE: [Solved] Load tips from external file... how?
Cool!!
![]() I'll let you know how it works... Seriously though... this should be a permanent part of your tutorials or documentation... all I kept thinking yesterday is about how nice it would be to have all the lengthy tips removed from the title attributes and stuck in their own single file. Plus, then I could include more HTML with the tip text rather than trying to embed/escape all that junk in the title attribute. Alternatively, I was also thinking of converting my main tip file into it's own page so the user can see the "glossary" all in one place or individually via the tip. And the webmaster only has to edit one file when updating tips. |
|||
|
5th January, 19:26
Post: #7
|
|||
|
|||
|
RE: [Solved] Load tips from external file... how?
That's a pretty neat idea. You could even use the metadata plugin to apply different options for each tip directly on the elements themselves! I'll definitely look into making this a tutorial.
Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
5th January, 19:40
(This post was last modified: 5th January 19:48 by sparky672.)
Post: #8
|
|||
|
|||
|
RE: [Solved] Load tips from external file... how?
Sorry. This is not working.
![]() It just displays the title in a browser tooltip, not in a qTip... JS Code
Alternatively, this just displays "Loading..." in a qTip... JS Code
|
|||
|
5th January, 19:55
Post: #9
|
|||
|
|||
|
RE: [Solved] Load tips from external file... how?
Works fine as far as I can see... take a look: http://jsfiddle.net/fDavN/74/
Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
5th January, 20:04
(This post was last modified: 5th January 20:21 by sparky672.)
Post: #10
|
|||
|
|||
RE: [Solved] Load tips from external file... how?
(5th January 19:55)Craig Wrote: Works fine as far as I can see... take a look: http://jsfiddle.net/fDavN/74/ Ah! I found your typo... ![]() api.elements.content.load('/ws/includes/tips.html #'+title); should have been... api.elements.content.load('/ws/includes/tips.html #'+id); YES!... it is working now!! After beating on my head for two days... it's working. This is awesome... everything remotely stored in an HTML file.... neato! THANK-YOU!! For the reader: here is my working code altered slightly for jsfiddle to simulate the external file... http://jsfiddle.net/JN3BG/ |
|||
|
5th January, 20:32
Post: #11
|
|||
|
|||
|
RE: [Solved] Load tips from external file... how?
Ah yes, I'll edit it with the fix. Great to see its working sparky, definitely a great idea. One fallback I can see however is that every tip will need atleast one AJAX call... perhaps you could include the tooltips file within the page itself i na hidden div, or even perhaps a hidden iframe. That way you can avoid it.
Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
5th January, 20:38
Post: #12
|
|||
|
|||
RE: [Solved] Load tips from external file... how?
(5th January 20:32)Craig Wrote: .... One fallback I can see however is that every tip will need atleast one AJAX call... What is/are the downside(s) to this? (5th January 20:32)Craig Wrote: ...perhaps you could include the tooltips file within the page itself i na hidden div, or even perhaps a hidden iframe. That way you can avoid it. If I do that, then it won't be able to double as an external glossary or FAQ page. |
|||
|
5th January, 23:41
Post: #13
|
|||
|
|||
|
RE: [Solved] Load tips from external file... how?
Well mostly just load on the server. But then it depends if you've optimized it specifically for this (which I doubt
). Using it in an iframe can still give you the same functionality, and still allows you to use it as a glossary since the iframe's content is just the external page you were calling in the .load() method. Here's an example of this using an iframe: HTML Code
JS Code
This is probably a better solution, since it results in less code. Just make sure you're iframe content is in the same domain and is hidden from view and you're set! Plus no nasty AJAX call for every qTip on the page! Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
5th January, 23:46
Post: #14
|
|||
|
|||
RE: [Solved] Load tips from external file... how?
(5th January 23:41)Craig Wrote: Well mostly just load on the server. Thanks for that! Yeah, you're right... the iframe is loading from another file anyway so my idea can still be implemented. I'm not sure how much load or what's really happening though... It seems like (with Safari anyway) that it's cached in the browser. First load of the first tip results in a little lag but then subsequent calls to the tips pop right up. Your idea is better and I'll probably do it... I'm all about efficient code. |
|||
|
6th January, 02:56
Post: #15
|
|||
|
|||
|
RE: [Solved] Load tips from external file... how?
Yeah the iframe idea is simply load-saving. You fetch all the tooltips at once instead of fetching the page each time a tooltip is opened, resulting in quite a significant bandwidth saving if the page is big.
Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
9th January, 19:31
Post: #16
|
|||
|
|||
RE: [Solved] Load tips from external file... how?
(5th January 23:41)Craig Wrote: Here's an example of this using an iframe: I tried this and nothing happens. No qTip. |
|||
|
11th January, 09:42
Post: #17
|
|||
|
|||
|
RE: [Solved] Load tips from external file... how?
Any errors sparky?
Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
11th January, 15:41
Post: #18
|
|||
|
|||
|
RE: [Solved] Load tips from external file... how?
No errors. I put the iFrame line outside of my content but still inside the body. Hover does nothing... no qTip, just the default tooltip.
I was playing around with it. Instead of hiding the iframe, I just placed it inline and it strangely blocks my page content. I mean that I set the iframe to a fixed width of 100px square and I can see it, but everything downstream of it will not show on the page. (this is probably an HTML problem I had not enough time to investigate). However, no matter where I placed it, no matter what size I made it, even if I placed it -10000 pixels off the page, the qTips will not show up. One exception, when I place it AFTER the qTip JS, a blank qTip appears; but that's only because the JS is before the iframe. |
|||
|
11th January, 17:42
Post: #19
|
|||
|
|||
|
RE: [Solved] Load tips from external file... how?
sparky, run your HTML through the W3C Validator to see if you've got any errors in there. Other than that it would be great if you could setup a jsFiddle test case with this.
Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
11th January, 18:00
Post: #20
|
|||
|
|||
RE: [Solved] Load tips from external file... how?
(11th January 17:42)Craig Wrote: sparky, run your HTML through the W3C Validator to see if you've got any errors in there. Other than that it would be great if you could setup a jsFiddle test case with this. 1. It's all green at the w3c validator. 2. Not really sure how to set this JSfiddle up correctly since the external tip file is stored on my server. Here it is but it doesn't work because I left the iframe "src" blank. http://jsfiddle.net/BuQtu/ |
|||
|
12th January, 09:47
Post: #21
|
|||
|
|||
|
RE: [Solved] Load tips from external file... how?
Seems to be working great once the iframe src is set
http://jsfiddle.net/BuQtu/5/Just have to make sure the iframe contents are on the same server due to Cross-Domain limitations. Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
12th January, 15:06
Post: #22
|
|||
|
|||
RE: [Solved] Load tips from external file... how?
(12th January 09:47)Craig Wrote: Seems to be working great once the iframe src is set JSfiddle not working great here. I'm in both Safari (Mac) and Firefox (Mac). Just to be clear, I'm not talking about my page... the JSfiddle page itself (http://jsfiddle.net/BuQtu/5/) is not working in Safari or Firefox. I'm now seeing just an empty qTip popup. There are no errors and it does not say "loading..."I've attached a screenshot from Firefox. ![]() I recall seeing that condition on my page once too but it depended on where I placed the iframe code within the HTML. (12th January 09:47)Craig Wrote: Just have to make sure the iframe contents are on the same server due to Cross-Domain limitations. they are. |
|||
|
12th January, 15:24
Post: #23
|
|||
|
|||
|
RE: [Solved] Load tips from external file... how?
For some reason you need to hit "Run" again once it's loaded. Must be a fiddle-related script as you're normally not allowed to link directly to the resulting page (I'm an elite haxxor...
)
Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
12th January, 15:37
Post: #24
|
|||
|
|||
RE: [Solved] Load tips from external file... how?
(12th January 15:24)Craig Wrote: For some reason you need to hit "Run" again once it's loaded. Must be a fiddle-related script as you're normally not allowed to link directly to the resulting page (I'm an elite haxxor... ...hitting "Run" in Safari makes no difference here. ...it only works after hitting "Run" in Firefox. So now after testing this exact code on my production page... - seems to be working in IE8 and Firefox. - does NOT work in Safari. (getting the empty qTip) |
|||
|
12th January, 16:55
Post: #25
|
|||
|
|||
|
RE: [Solved] Load tips from external file... how?
sparky, any you getting any errors at ALL? Try and console.log() the iframe contents and see if its actually loading.
Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)

Search
Member List
Calendar
Help










![[Image: jsfiddle.th.jpg]](http://img193.imageshack.us/img193/5117/jsfiddle.th.jpg)