Nerbert
Active member
I'm working on an AJAX project for the thread page and jQuery isn't working. The jQ syntax is not recognized and the jQ functions aren't recognized as such.
I tried both <xen:require js="js/graffiti/graffiti.js" /> in the template and
$template->addRequiredExternal('js', 'js/graffiti/graffiti.js'); in my listener script.
Here's my JS file: (See my comments within)
The unrecognized functions are used in js.xenforo/full/acp_quicksearch.js, which I am using as a model.
What am I doing wrong?
I tried both <xen:require js="js/graffiti/graffiti.js" /> in the template and
$template->addRequiredExternal('js', 'js/graffiti/graffiti.js'); in my listener script.
Here's my JS file: (See my comments within)
Code:
/** @param {jQuery} $ jQuery Object */
!function($, window, document, _undefined)
{
console.info("graffiti") // this shows in the console before "XenForo.init() 220ms. jQuery 1.11.0/1.2.8-dev"
XenForo.Graffiti = function($form) {
var f = $("#graffiti_form");
alert(f.id); // alerted "undefined"
$('#graffiti_display').empty();
xhr = XenForo.ajax(
//$form.attr('action'), // didn't recognize this function
$form.action,
$form.serializeArray(), // throws error "$form.serializeArray" is not a function
function(ajaxData) {
if (XenForo.hasResponseError(ajaxData))
{
return false;
}
$('#graffiti_display').empty().append(ajaxData.templateHtml);
}
)
};
}
(jQuery, this, document);
The unrecognized functions are used in js.xenforo/full/acp_quicksearch.js, which I am using as a model.
What am I doing wrong?