I am new to jquery. I am using the Notyfy jQuery plugin. I want to show the notification bar with the message on specific condition. want to show the success and error message on specific condition
I want to do something like this. please correct my code so I can successfully implement this library
var notyfy-success = notyfy({text: 'successfully deleted'});
var notyfy-error = notyfy({text: 'somethings wrong'});
$(document).ready(function(){
if (true){
alert("hello");
notyfy-success.show('success bar ');
}else{
notyfy-error.show('error bar ');
}
});
If you use TRUE in if() condition the else script never be performed. (buy i think u know that). However...
I see the Documentation of the plugin and you not need to instantiate notyfy-success
and notyfy-error
define them only (TAKE CARE the character -
inside a variable name is not a good idea, use _
), and then inside "if" statement instantiates them:
var _delete = true, //is the returned value of a action that delate somethig set to "false" and try
notyfy_success, notyfy_error;
$(document).ready(function(){
if (_delete){
notyfy_success = notyfy({text: 'successfully deleted'});
}else{
notyfy_error = notyfy({text: 'somethings wrong'});
}
});
Now, on document ready the notyfy_success notification will show, if you set _delete
to false
notyfy_error will show instead notyfy_success.
http://jsfiddle.net/Frogmouth/43C7Q/
OMG... my english is terrible... I'm so sorry. I hope you can understand.. my bad.