Emma Emma - 7 months ago 10
Perl Question

Hide model in js using perl

I've some confusion regarding using modals in js in Perl, In my case i have a view File having button

<button type="button" id="helloWorld" ></button>


and an array is requested when user clicks on
helloWorld
i-e JS is used to call array from controller,

var URL = encodeURI("/helloWorld");
$('#modal').load(URL, function(result){
$('#Modal').modal({show:true});
});


so that returned data is used in load modal, but now i want to hide the modal and show an error message if the returned array is NULL,
how is it possible to load data only if array is not NULL
can any one give me some tips to solve the above issue

Answer

you can do like the following to check the result value if its not NULL then show the modal else do something else.

if (result) {
    $('#myModal').modal({show:true});
}else { # do someting if required }