I have a working jquery function which I can call like this through php
if (!order)
{ echo '<script>
$(function() {
$this = $("#ui-accordion-accordion-panel-0");
// parent tab
var parent = $("#accordion").parent();
//parent.adderror();
// the content
$this.adderror();
// the header
var header = $this.attr("aria-labelledby");
$("#"+header).adderror();
// the tab
var tab = parent.attr("aria-labelledby");
$("#"+tab).parent().adderror();
});
</script>';}
I want to make this a global function (even better if defined externally in a .js file) that I can call from wherever I want in my php, which takes the panel as a parameter.
So I would basically call - show_error("#ui-accordion-accordion-panel-0"). How could I do this? When I tried defining function, and then calling it - there was no change whatsoever. Was using through techinques defined here to no avail (var functionName = function() {} vs function functionName() {})
Thanks in advance
Ok, I have now an error.js file, which I have linked appropriately ( )
function show_error(selector) {
var $this = $(selector);
// parent tab
var parent = $("#accordion").parent();
//parent.adderror();
// the content
$this.adderror();
// the header
var header = $this.attr("aria-labelledby");
$("#"+header).adderror();
// the tab
var tab = parent.attr("aria-labelledby");
$("#"+tab).parent().adderror();
}