Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
simple VLT messages - code in coffeescript: sending messages to server and receive responses, both in JSON
$(document).ready ->
tester = $('nav#tester')
if tester.length > 0
tester.find('a').click (event) ->
$('<div/>',{'class': 'query', html: JSON.stringify($(this).data('json'))}).appendTo('div#tester_commands')
dataType: 'json',
url: $(this).attr('href'),
type: $(this).attr('data-method').toUpperCase(),
data: $(this).data('json'),
success: (data, textStatus, jqXHR) ->
$('nav#tester > ul > li > a').each ->
$(this).attr('href', $(this).attr('href').replace('0', )
$(this).data('json').id = if $(this).data('json').id == 0
$(this).parent().css('visibility', 'visible')
$('<div/>',{'class': 'response', html: JSON.stringify(data)}).appendTo('div#tester_commands')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.