var $select = $('select.TitlePrefix');
$select.bind('XFSetPrefix', function(e)
{
var $link = e.link; // just in case you want it
if ($select.val() == 13)
{
XenForo.ajax('ragtek_formtemplate', {}, function(ajaxData)
{
if (XenForo.hasTemplateHtml(ajaxData))
{
$(a.templateHtml).xfInsert('appendTo', $ragtek_editortemplates_container, 'xfFadeIn');
}
else
{
console.warn("error");
}
});
}
});
You could do something like this:
Code:var $select = $('select.TitlePrefix'); $select.bind('XFSetPrefix', function(e) { var $link = e.link; // just in case you want it if ($select.val() == 13) { XenForo.ajax('ragtek_formtemplate', {}, function(ajaxData) { if (XenForo.hasTemplateHtml(ajaxData)) { $(a.templateHtml).xfInsert('appendTo', $ragtek_editortemplates_container, 'xfFadeIn'); } else { console.warn("error"); } }); } });
!function($, window, document, _undefined) {
var $select = $('select.TitlePrefix');
$select.bind('XFSetPrefix', function(e) {
var $link = e.link; // just in case you want it
console.log('selected');
if ($select.val() == 1) {
XenForo.ajax('ragtek_formtemplate', {}, function(ajaxData) {
if (XenForo.hasTemplateHtml(ajaxData)) {
$(a.templateHtml).xfInsert('appendTo', $ragtek_editortemplates_container, 'xfFadeIn');
}
else {
console.warn("error");
}
});
}
});
}
(jQuery, this, document);
$('select.TitlePrefix').bind('XFSetPrefix', function(){confirm('hello world')});
$('select.TitlePrefix').bind('XFSetPrefix', function(){confirm('hello world')});
$('select.TitlePrefix').bind('XFSetPrefix', function(){confirm('hello world')});
!function($, window, document, _undefined) {
$('select.TitlePrefix').bind('XFSetPrefix', function(){confirm('hello world')});
}
(jQuery, this, document);
isn'tIt sounds to me like you're running that code before the select exists. If that code is in the head tag, then that would be the case - you should really only do your binding on document ready.
Or better yet: look at event delegation.
!function($, window, document, _undefined) {
..
}
(jQuery, this, document);
vBulletin.events.systemInit.subscribe(function()
$(document).ready();
$(document).ready(function() {
XenForo.register('select.TitlePrefix', 'Ragtek.ModeratorForum');
});
There's a chance that might not fire actually - I'd go with one or the other.You could be doubly sure...
Code:$(document).ready(function() { XenForo.register('select.TitlePrefix', 'Ragtek.ModeratorForum'); });
We use essential cookies to make this site work, and optional cookies to enhance your experience.