views:

159

answers:

1

I am having a couple problems trying to manually insert some jQuery features into a wordpress theme. I have a lightbox wordpress plugin that is jQuery based that is working fine.

So if I manually load the jQuery script into wordpress the functions seem to work but instead of say a slide being hidden it is revealed when it should still be hidden. Or a pop up that should work is already being shown instead of hidden. I don't think I'm supposed to manually include the jQuery into my skin but using the wp_enqueue_script('jquery'); doesn't seem to be resolving my issues either.

<script src="http://platform.twitter.com/anywhere.js?id=i5CnpkmwnlWpDdAZGVpxw&amp;v=1" type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function(){

    $(".btn-slide").click(function(){
      $("#twitpanel").slideToggle("slow");
      $(this).toggleClass("active");
    });

});
</script>

<div id="tweetit"><a class="btn-slide">Tell em'</a>
            <div id="twitpanel"></div>
            <script type="text/javascript">

              twttr.anywhere(function (T) {

                T("#twitpanel").tweetBox({
                  height: 100,
                  width: 225,
                  defaultContent: "Some Random Text"
                });

              });

            </script>

            </div></h2>

Like I said it works but in the reverse fashion that it should be.

I think I'm just loading in something wrong?

TIA, Chase

A: 

maybe you need to default the div to hidden?

<div id="twitpanel" style="display:none"></div>

or

<div id="twitpanel" style="visibility:hidden"></div>
house9
No because the way the function works is it changes the class of the link not the div. So if it is hidden then when you click the link it just changes the class of the link and not the div. You should not need to modify the css of the div to make it work. Like I said it slides up to hide the div but should just be hidden initially and not showing.
codeisforeva
slideToggle is going to change the divsee http://api.jquery.com/slideToggle/"If the element is initially displayed, it will be hidden; if hidden, it will be shown."
house9
"If the element is initially displayed, it will be hidden" .. from the API. So since it's already displayed it should be hidden. Therefore something isn't right. Adding display: none property makes it not even show period. You click on it and it slides a bit then shows nothing.
codeisforeva
ok, I must have not understood the issue correctly. Is it possible js errors are being thrown and stopping stuff from executing? Have you checked it out with Firebug?
house9