jsFiddle question

← Ask a Question — Started 4 Aug, 2011

leesester
4 Aug, 2011, 4:01 pm (This post was last modified: 5 Aug, 2011 4:49 am by leesester.)
I have been trying out jsFiddle, and its really neat. I can do tests and stuff and then try it out on leefish.

I found a cool proto/scripty tabs script that seemed to be perfect for my needs, but it only works on jsFiddle. It doesn't work on my testboard.

I looked a bit closer and saw that my script only works if I have nowrap(body) or nowrap(head) set as the framework in jsFiddle. What does this mean? And, more importantly - what do I need to do to the script to make it work in mybb?

Link to my jsFiddle thing

http://jsfiddle.net/leefish/M2VvX/

EDIT: I had a look in the jsFiiddle help - and I see that I am missing a window on load. Or something.
[Image: leelink.gif]
Have you got a link to where you've exported the script and it doesn't work? It will be easier to debug. Strange that jsFiddle doesn't seem to change when you alter the framework.

Basically, there'll be some piece of code you'll need to add in to tell the script to run. This is it:

Code:
document.observe("dom:loaded", function() {
    indextabs.createTabs();
});

This tells Prototype to observe when the DOM is loaded (when all the page is loaded, but before style and images are loaded). When it's ready, it runs the function that creates the tabs.
aha. I had changed it to

Code:
Event.observe(window, 'load', function() {
    indextabs.createTabs();
});

Which somehow mysteriously broke it Smile

Now all is fixed. Just need to get it ready to implement on the real board now.
[Image: leelink.gif]
World's slowest coder reporting in......

so, I have not given up on this, and I do have this working on my test board, but I have TWO problems with it.

Problem1: I am not able to add more than one category to a tab. This sort of makes the tab kind of pointless imo.

Problem2: I cannot work out how to get the state to persist (i.e. when a user has selected tab whatever, when they return to the page it is no longer at the selected tab but at the first tab)

I did a lot of googling, and have read half of stackoverflow.com, but no luck. So far, the only simple tab solution I have found WHICH PERSISTS is labroccas Tabbed Menu, which is a pluginified version of this:

http://www.dynamicdrive.com/dynamicindex...ontent.htm

So - my question is, how would I change my existing script to harness the state change and ADD the ability to show more than one category in a tab?

I think the more than one category is somehow here >>
Code:
if (content) {
                this.tabs.pluck("id").each(function(elid) {
                    $(elid).className = "";
                    $(elid + "_data").hide();
                });

And I don't have the foggiest on the persist.

Course, I see that having the tab persist is a VERY popular thing (I see requests for the Profile module to have this feature) so I hope this question will pique your interest Big Grin
The best method to persist is with cookies; probably the only way. When a tab is clicked, a cookie is added/updated with the ID of the tab then, when the page is loaded, the script looks for the cookie to see if it should set a tab as active and select it.

With more than one category I'm not so sure. I can take a look at it if you want to PM me some login details to fiddle with it?
(22 Mar, 2012 8:34 am)Tomm Wrote:  The best method to persist is with cookies; probably the only way. When a tab is clicked, a cookie is added/updated with the ID of the tab then, when the page is loaded, the script looks for the cookie to see if it should set a tab as active and select it.

With more than one category I'm not so sure. I can take a look at it if you want to PM me some login details to fiddle with it?

Ok, I will PM with the link. Thank you for taking a look, and please excuse the state of the test board Big Grin
[Image: leelink.gif]
Still plodding along Big Grin

I found this:

http://livepipe.net/extra/cookie

That looks very interesting as it seems from reading that Prototype has no native cookie management. for js.
MyBB has cookies built in (in ./jscripts/general.js) which we can use. I'll try and take a look today or tomorrow, have a lot on at the minute. Smile
Thanks Tomm - there is no rush, and I am continuing to look about for solutions myself Big Grin

User(s) browsing this thread: 1 Guest(s)