class SuperInteraction::Beyond

Attributes

commands[RW]

Public Instance Methods

ajax_get(url) click to toggle source
# File lib/super_interaction/beyond.rb, line 63
def ajax_get(url)
  cmd("$.get('#{url}');")
end
alert(message) click to toggle source
# File lib/super_interaction/beyond.rb, line 26
def alert(message)
  cmd("alert('#{helpers.j(message)}');")
end
b_alert(class_type, text) click to toggle source
# File lib/super_interaction/beyond.rb, line 67
def b_alert(class_type, text)
  cmd("if (typeof($.alert) == undefined) { alert('#{helpers.j(text)}'); } else { $.alert.#{class_type}('#{helpers.j(text)}'); }")
end
b_danger(message) click to toggle source
# File lib/super_interaction/beyond.rb, line 17
def b_danger(message)
  b_alert('danger', message)
  self
end
b_notice(message) click to toggle source
# File lib/super_interaction/beyond.rb, line 12
def b_notice(message)
  b_alert('info', message)
  self
end
b_success(message) click to toggle source
# File lib/super_interaction/beyond.rb, line 22
def b_success(message)
  b_alert('success', message)
end
close() click to toggle source

關閉 Modal

# File lib/super_interaction/beyond.rb, line 41
def close
  cmd("$.uniqModal().modal('hide');")
end
cmd(js_code) click to toggle source
# File lib/super_interaction/beyond.rb, line 71
def cmd(js_code)
  self.commands ||= []
  self.commands.push(js_code)
  self
end
modal(partial: nil, size: 'md', title: '', desc: '', classname: '') click to toggle source

modal 裡如果有 javascript 需寫在 .modal 層 size: sm / md / lg / xl / xxl 注意:不要包 respond_to :js 會有問題

modal_saved_rediret_to(message, redirect_url) click to toggle source
modal_saved_reload(message) click to toggle source
redirect_to(url) click to toggle source

導入頁面

# File lib/super_interaction/beyond.rb, line 51
def redirect_to(url)
  cmd("Turbolinks.visit('#{url}');");
end
reload() click to toggle source

重新讀取頁面

# File lib/super_interaction/beyond.rb, line 46
def reload
  cmd("Turbolinks.visit(location.toString());");
end
run() click to toggle source
# File lib/super_interaction/beyond.rb, line 8
def run
  context.render js: (commands || []).join(";"), layout: false
end