I am trying this code to update the fallback of tipsy plugin.
How can I access the variable a outside of first function ? I can override the variable to make the update, correct ?
<script type="text/javascript">
$(document).ready(function () {
var a ="Login";
$("#login_form").submit(function () {
var formdata = $("#login_form").serializeArray();
$.ajax({
url: "ajax_login.php",
type: "post",
dataType: "json",
data: formdata,
success: function (data) {
if (data.livre === 'complete') {
var a ="success";
} else
var a = "Error";
}
});
return false;
});
});
</script>
<script type='text/javascript'>
$(document).ready(function () {
$('.login_fields input[rel=tipsy]').tipsy({gravity: 'w', trigger: 'manual', fallback: a }); // a is not defined
});
</script>
It is not possible to change the
fallbackproperty of your Tipsy objects after they’ve been created without hacking the tipsy plugin itself.Given the
fallbackparameter is a string, it is interpreted as soon as the$().tipsy({...})function is executed. So changing the value of variableaafterwards will not change thefallbackparameter.I first thought that directly updating the
fallbackproperty from the$.fn.tipsy.defaultsobject would make it, but when a newTipsyobject is created, thefallbackproperty is basically copied in it, so it will store the initial value offallbackforever.One solution would be to fork the Tipsy project and change the
fallbackproperty to accept either a string or afunction(). Like this it would be possible to do something like:fallback: function (){ return a;}.