Saturday, 15 September 2012

javascript - Noty (notifier) is not working inside a function -



javascript - Noty (notifier) is not working inside a function -

i have misterious problem noty plugin click. when create notifier explained on site works fine, when set same statement function called @ "onclick" event button, doesn't work. there no noty-notification coming, no errors, nil happens if press button. when remove noty-thing , add together normal "alert" statement works fine. there have missed or bug?

the original code looks like:

<head> <script type="text/javascript" src="ajax/libs/jquery/1.7/jquery.min.js"></script> <script type="text/javascript" src="js/noty/jquery.noty.js"></script> <script type="text/javascript" src="js/noty/layouts/top.js"></script> <script type="text/javascript" src="js/noty/themes/default.js"></script> </head> ... <script> var noty = noty({text: 'noty - jquery notification library!'}); </script>

when set same statement next function, noty don't works anymore.

<head> <script type="text/javascript" src="ajax/libs/jquery/1.7/jquery.min.js"></script> <script type="text/javascript" src="js/noty/jquery.noty.js"></script> <script type="text/javascript" src="js/noty/layouts/top.js"></script> <script type="text/javascript" src="js/noty/themes/default.js"></script> </head> ... <a href="#" onclick="test_function(); homecoming false;" class="btn">klick</a> ... <script> function test_function(){ var noty = noty({text: 'noty - jquery notification library!'}); } </script>

even if alter var noty var n (or else) nil changes, stated in 1 stackoverflow question before.

thanks in advance. regards, john.

it improve if utilize this:

<head> <script type="text/javascript" src="ajax/libs/jquery/1.7/jquery.min.js"></script> <script type="text/javascript" src="js/noty/jquery.noty.js"></script> <script type="text/javascript" src="js/noty/layouts/top.js"></script> <script type="text/javascript" src="js/noty/themes/default.js"></script> </head> <script> $("#element").click(function(){ var n = noty({text: 'noty - jquery notification library!'}); }); </script> <a id="element" href="#" onclick="return false;" class="btn">klick</a>

and of course of study utilize "id" on element wish bind noty. work perfectly.

check out working illustration here: jsfiddle

javascript jquery function notifications

No comments:

Post a Comment