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
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
$jQuery is not defined error from helpers.php
#1
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());
}
?>
  Reply
#2
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...

  Reply
#3
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.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)