The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once



UserSpice
$jQuery is not defined error from helpers.php - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23)
+--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26)
+--- Thread: $jQuery is not defined error from helpers.php (/showthread.php?tid=543)



$jQuery is not defined error from helpers.php - muhammedc - 04-26-2017

In the helpers.php file the following function exists:

function display_errors($errors = array()){
$html = '<ul class="bg-danger">';
foreach($errors as $error){
if(is_array($error)){
echo "<br>";
$html .= '<li class="text-danger">'.$error[0].'</li>';
$html .= '<script>$jQuery("#'.$error[0].'").parent().closest("div").addClass("has-error");</script>';
}else{
$html .= '<li class="text-danger">'.$error.'</li>';
}
}
$html .= '</ul>';
return $html;
}

When I call this function, I always get $jQuery is not defined error. Why would this occur? What am I missing?

I am calling the function using the following code:

<?php echo resultBlock($errors,$successes);
if (!$form_valid && Input::exists()){
echo display_errors($validation->errors());
}
?>



$jQuery is not defined error from helpers.php - muhammedc - 04-26-2017

I think the $ from $jQuery needs to be removed. If I removes the $ sign, the error disappears. Also why is there an
Code:
echo <br>
statement... it seems to just add multiple <br> based on the count of errors being displayed which makes things look not so pretty...




$jQuery is not defined error from helpers.php - mudmin - 04-27-2017

I'm with you on the $. I'll take a look at that.

as far as the
goes, it's absolutely crazy how different versions of chrome/firefox/opera/safari/edge/ie display the same content differently and when you throw in apache/nginx/iis into the mix, there are so many different combinations of how content gets rendered. Without that br, the errors were sliding under the nav bar in some of those combinations, so it was an ugly fix. Every other fix broke something new in a different browser/server combo.