chinezan

Untitled

Dec 4th, 2017
597
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #coffee script for new question
  2. new_question = ->
  3.   $('body').on 'click', '.ask_question', (e) ->
  4.     e.preventDefault()
  5.     $(this).hide()
  6.     new_question_form = JST["templates/new_question_form"]({})
  7.     # add form before/above exists questions table
  8.     $(new_question_form).insertBefore('.exists_questions')
  9.     $('form.new_question').on 'click', '.create_question', (e) ->
  10.       $('form.new_question')
  11.         .bind 'ajax:success', (e, data, status, xhr) ->
  12.           $('#errors_alert').remove()
  13.           question = $.parseJSON(xhr.responseText)
  14.           new_question = JST["templates/new_question_template"] ({ question: question })
  15.           $('.exists_questions > tbody:last').append(new_question)
  16.           # remove form, show link
  17.           $('.new_question').remove()
  18.           $('.ask_question').show()
  19.  
  20.         .bind 'ajax:error', (e, xhr, status, error) ->
  21.           $('#errors_alert').remove()
  22.           response = $.parseJSON(xhr.responseText)
  23.           errors = JST["templates/errors"]({ title: response.title, resourse_id: response.resource.id, errors: response.errors })
  24.           $(errors).insertBefore('form.new_question')
  25.     # 'cancel creating question' button actions
  26.     $('.cancel_create_question').click (cancel) ->
  27.       cancel.preventDefault()
  28.       $('.new_question').remove()
  29.       $('.ask_question').show()
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×