DedalusNine
DedalusNine

Reputation: 47

calling jQuery inside a javaScript function, from a method

Im trying to call a jQuery inside a javaScript function, but it doesnt work, what I am doing wrong?

<script type="text/javascript" language="javascript">

        function Test() {
            $(document).ready(function () {
                $("#pezz").animate({
                    left: '+=150px',
                    height: '+=20px',
                    width: '+=20px'
                });
            });
        }
    </script>

call from a method int the Bean

RequestContext.getCurrentInstance().execute("Test");

UPDATE:

As Gibberish suggested I change the Script to this:

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

 function Test() {
$("#pezz").animate({
  left: '+=150px',
  height: '+=20px',
  width: '+=20px'
});
}
</script>

But Works only once, Its supposed to work every time some condition is reached in the method, what canI do to fix this?

Upvotes: 2

Views: 3489

Answers (1)

cssyphus
cssyphus

Reputation: 40038

Restructure like this:

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

  function Test() {
    $("#pezz").animate({
      left: '+=150px',
      height: '+=20px',
      width: '+=20px'
    });
  }
</script>

Upvotes: 1

Related Questions