techtir
29 Sep 2009, 11:33
I was recently adding a spoiler BB code from the site here.
(Sadly I forget which thread I found it).
It didn't work as expected. I was using it to "fold Sections"
Demo http://www.techtir.ie/forums/showthread.php?t=19
Examination suggested that using {option} or {param} in a javascript called function is simply not going to work sensibly if there are multiple instances in the same page. The BB Code will expand and put the javascript function multiple times. Any {option} or {param} in the last instance on the page will "fill in" the values when you click anywhere.
Also I realised that if a BB code has a Javascript function, it will be inserted N times on the page for N instances of the object.
So for now I put the function in headinclude
The BB code manager only has the instance code that calls it with {option} as a parameter to the javascript function.
My suggestions:
NEVER use {option} or {param} in a function.
A later version of BB manager should have an "include once in header" tag for a function.
For those interested here is the code.
(Make sure the <img src= paths match your install from root of web site, both in the javascript function and in the BB code definition that calls it.)
It allows nested folded sections/spoilers
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
In the BB code Manager
Answers
Ans
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Lots of body, inc BBcode for images, tables & video
(Sadly I forget which thread I found it).
It didn't work as expected. I was using it to "fold Sections"
Demo http://www.techtir.ie/forums/showthread.php?t=19
Examination suggested that using {option} or {param} in a javascript called function is simply not going to work sensibly if there are multiple instances in the same page. The BB Code will expand and put the javascript function multiple times. Any {option} or {param} in the last instance on the page will "fill in" the values when you click anywhere.
Also I realised that if a BB code has a Javascript function, it will be inserted N times on the page for N instances of the object.
So for now I put the function in headinclude
The BB code manager only has the instance code that calls it with {option} as a parameter to the javascript function.
My suggestions:
NEVER use {option} or {param} in a function.
A later version of BB manager should have an "include once in header" tag for a function.
For those interested here is the code.
(Make sure the <img src= paths match your install from root of web site, both in the javascript function and in the BB code definition that calls it.)
It allows nested folded sections/spoilers
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
In the BB code Manager
Answers
Ans
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Lots of body, inc BBcode for images, tables & video