F
Floris
Guest
Thanks for part 2. *loads*
It sounds like you just want to change some text based on the value of a form element (like a radio button)? If so, you should be able to bind a click event to input:radio[name=xxx], and inside the callback look at the checked value and update accordingly. Also see: http://api.jquery.com/val/OK, here's a question... if I wanted to modify the contents of a <div> based on what is selected in a form, could I modify the original code to work for what I want? Because I am building the next version of BB Code Manager that'll support an arbitrary number of required options (gotta figure out help display for that...), and replaces it... However, the description setups that I'd want to set for the replacement fields, would be different.
Any update on this?Aah yes, will do, sorry
I've yet to lear how to firebug to debug javascript... will try howeverJust use a javascript debugger, for example firebug^^
I'm actually using beta2, however i was wrong: it's not Unknow error, but Unspecified ErrorThe 'unknown error' thing seems to be new with beta 3 - we are still trying to track it down.
I'll post the source code tonight for anyone interested.
Posted now: http://xenforo.com/community/threads/code-from-have-you-seen-videos.7236/#post-114581Any update on this?
Adapted the javascript to an addon I'm working on as best I can using the non-HD video, but jQuery keeps spitting out errors. Would appreciate being able to look at the original for reference.
Awesome, thanks Kier!
/** @param {jQuery} $ jQuery Object */
!function($, window, document, _undefined)
{
XenForo.CommentFeedLoader = function($link)
{
$link.click(function(e)
{
e.preventDefault();
var oriurl = $link.attr('href').split('?');
var newurl = oriurl[0] + "comments/?" + oriurl[1];
XenForo.ajax(
newurl,
{},
function(ajaxData, textStatus)
{
if (ajaxData.templateHtml)
{
new XenForo.ExtLoader(ajaxData, function()
{
$(ajaxData.templateHtml).xfInsert('replaceAll', '#mediaComments', 'xfShow');
});
}
}
);
});
}
// *********************************************************************
XenForo.register('#CommentFeed div.PageNav a[href]', 'XenForo.CommentFeedLoader');
}
(jQuery, this, document);
XenForo.CommentPoster = function($form)
{
$form.bind('AutoValidationComplete', function(e)
{
$form.find('input:submit').blur();
$form.find('textarea[name="message"]').val('').blur();
if (e.ajaxData.status)
{
$('#CommentStatus').text(e.ajaxData.status);
}
XenForo.ajax(
e.ajaxData.newurl,
{},
function(ajaxData, textStatus)
{
if (ajaxData.templateHtml)
{
new XenForo.ExtLoader(ajaxData, function()
{
$(ajaxData.templateHtml).xfInsert('replaceAll', '#mediaComments', 'xfShow');
});
}
}
);
});
}
I have a comment form here: http://xen1.8wayrun.com/media/nicovideo-test-video.6/I have a suspicion that I know what you're trying to do, and I think I can show you a better way, but I need to know your intentions there first.
XenForo.CommentPoster = function($form)
{
$form.bind('AutoValidationComplete', function(e)
{
if (e.ajaxData.status)
{
$('#CommentStatus').text(e.ajaxData.status);
}
var StatusEditor,
$textarea = $form.find('textarea[name="message"]')
.val('')
.blur();
if (StatusEditor = $textarea.data('XenForo.StatusEditor'))
{
StatusEditor.update();
}
XenForo.ajax(
e.ajaxData.newurl,
{},
function(ajaxData, textStatus)
{
if (ajaxData.templateHtml)
{
new XenForo.ExtLoader(ajaxData, function()
{
$(ajaxData.templateHtml).xfInsert('replaceAll', '#mediaComments', 'xfShow');
});
}
}
);
});
}
/** @param {jQuery} $ jQuery Object */
!function($, window, document, _undefined)
{
XenForo.CommentFeedLoader = function($link)
{
$link.click(function(e)
{
e.preventDefault();
var oriurl = $link.attr('href').split('?');
var newurl = oriurl[0] + "comments/?" + oriurl[1];
XenForo.ajax(
newurl,
{},
function(ajaxData, textStatus)
{
if (ajaxData.templateHtml)
{
new XenForo.ExtLoader(ajaxData, function()
{
$(ajaxData.templateHtml).xfInsert('replaceAll', '#mediaComments', 'xfShow');
});
}
}
);
});
}
// *********************************************************************
XenForo.CommentPoster = function($form)
{
// disables submit form to prevent multiple submissions
$form.bind('AutoValidationBeforeSubmit', function(e)
{
XenForo.MultiSubmitFix($form);
});
// updates comment list after validation
$form.bind('AutoValidationComplete', function(e)
{
// blurs focus away from submit button, dont see purpose of this line
$form.find('input:submit').blur();
// sets contents of a "status" DIV in template, removes status notice after 4 seconds
if (e.ajaxData.status)
{
$('#CommentStatus').text(e.ajaxData.status);
setTimeout(function() { $('#CommentStatus').text(''); }, 4000);
}
// gets information about the contents of text area
var StatusEditor,
$textarea = $form.find('textarea[name="message"]')
.val('')
.blur();
// clears contents of text area
if (StatusEditor = $textarea.data('XenForo.StatusEditor'))
{
StatusEditor.update();
}
// runs ajax refresher to update the list of comments and return to comment page 1
XenForo.ajax(
e.ajaxData.newurl,
{},
function(ajaxData, textStatus)
{
if (ajaxData.templateHtml)
{
new XenForo.ExtLoader(ajaxData, function()
{
$(ajaxData.templateHtml).xfInsert('replaceAll', '#mediaComments', 'xfShow');
});
}
}
);
});
}
// *********************************************************************
XenForo.register('#CommentFeed div.PageNav a[href]', 'XenForo.CommentFeedLoader');
XenForo.register('#CommentPoster', 'XenForo.CommentPoster');
}
(jQuery, this, document);[/[SIZE=18px]PHP[/SIZE]]
We use essential cookies to make this site work, and optional cookies to enhance your experience.