Reputation: 47
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
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