Cesy (
cesy) wrote in
dw_dev_training2009-09-21 08:05 am
Entry tags:
Javascript help
I am trying to implement a solution to Bug 581, and I need to do some Javascript that will make a hidden section appear when clicked on. So far I have this:
(and then the actual content in the span). What should my ShowTags() function actually do in order to change the style to display:inline? I found one example on the web, but it used fancy browser-sniffing, and it appears we have our own browser-sniffing module and I don't know how to adapt it for that.
$out .= "Click here to see all your tags";
$out .= "(and then the actual content in the span). What should my ShowTags() function actually do in order to change the style to display:inline? I found one example on the web, but it used fancy browser-sniffing, and it appears we have our own browser-sniffing module and I don't know how to adapt it for that.

no subject
$('#divid').toggle();
But since it doesn't, I'm not sure what the best way to do it is...
no subject
no subject
document.getElementById('divid').style.display = 'inline';I'm pretty certain this is supported by all of the major current browsers (going back a number of versions, even).
Having said that, like Cesy suggested in her reply, we could just include jQuery on this page, unless there's a reason it isn't currently?
no subject
no subject
no subject
$('divid')instead ofdocument.getElementById('divid').But the general idea is to have the div have a
display: hidden;property, and have the onclick handler for the div do$('divid').style.display = 'block';(or 'inline', depending on how you want it to look). If you want it to be able to toggle off again, just have your JS check to see if the div is hidden or shown first (by looking at the$('divid').style.displayproperty), and then do the opposite.no subject
<a class="tagslink" onclick=ShowTags();>Click here to see tags</a><span class="tagslist" style=display:none;>[Actual tags]</span>or code to that effect in the doc, and then in the header,
<script type=text/javascript>document.getElementById('tagslist').style.display = 'inline';</script>but that didn't seem to do the trick, and I know I should be putting the details of the function in there and so on. I really don't know very much javascript at all.
no subject
<span class="tagslist" id="tagslistid" style=display:none;>[Actual tags]</span>And you would then use:
<script type=text/javascript>document.getElementById('tagslistid').style.display = 'inline';</script>no subject
no subject
It's probably not a HUGE task, but it hasn't been done yet. I imagine that the FCKEditor is compatible with jQuery, and that's the bulk of it.
no subject
var $jQ = jQuery.noConflict();For anyone following along, this remaps the default jQuery $ to $jQ (and releases the $ back to whatever other library wants it), so
$(document)becomes$jQ(document).no subject
You can try it though! I dismissed it pretty easily, but admit I haven't done any thorough testing.