   target = ev.target
   method = target.getAttribute('method')
 
-  return unless target.getAttribute('data-tg-remote')? || target.getAttribute('tg-remote')?
+  return unless tgAttributeExists(target, 'tg-remote')
   ev.preventDefault()
 
   remote = setupRemoteFromTarget(target, method, target)

hasClass = (node, search) ->
  node.classList.contains(search)


setupRemoteFromTarget = (target, httpRequestType, form = null) ->
  httpUrl = target.getAttribute('href') || target.getAttribute('action')

  throw new Error("Turbograft developer error: You did not provide a URL ('#{urlAttribute}' attribute) for data-tg-remote") unless httpUrl

  if getTGAttribute(target, "remote-once")
    removeTGAttribute(target, "remote-once")
    removeTGAttribute(target, "tg-remote")

  options =
    httpRequestType: httpRequestType
    httpUrl: httpUrl
    fullRefresh: getTGAttribute(target, 'full-refresh')?
    refreshOnSuccess: getTGAttribute(target, 'refresh-on-success')
    refreshOnSuccessExcept: getTGAttribute(target, 'full-refresh-on-success-except')
    refreshOnError: getTGAttribute(target, 'refresh-on-error')
    refreshOnErrorExcept: getTGAttribute(target, 'full-refresh-on-error-except')

  new TurboGraft.Remote(options, form, target)

TurboGraft.handlers.remoteMethodHandler = (ev) ->
  target = ev.clickTarget
  httpRequestType = getTGAttribute(target, 'tg-remote')

  return unless httpRequestType
  ev.preventDefault()
