Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Zepto support #102

Closed
wants to merge 1 commit into from

1 participant

@mikekelly

The datalink script depends on jQuery global and uses the proprietary jQuery selector :script, neither of which are compatible with Zepto.

This PR overcomes these issues by introducing an alternative script that's compatible with Zepto.

@mikekelly mikekelly add alternative datalink implementation supporting Zepto
Zepto doesn't support proprietary jQuery CSS extensions,
and the default datalink script depends on jQuery global.
This alternative implementation overcomes both of these
issues.
f26e8ff
@mikekelly mikekelly closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 31, 2012
  1. @mikekelly

    add alternative datalink implementation supporting Zepto

    mikekelly authored
    Zepto doesn't support proprietary jQuery CSS extensions,
    and the default datalink script depends on jQuery global.
    This alternative implementation overcomes both of these
    issues.
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 0 deletions.
  1. +14 −0 vendor/assets/javascripts/backbone_zepto_datalink.js.coffee
View
14 vendor/assets/javascripts/backbone_zepto_datalink.js.coffee
@@ -0,0 +1,14 @@
+extensions =
+ backboneLink: (model) ->
+ $(this).find('input,select,textarea').each ->
+ el = $(this)
+ name = el.attr 'name'
+ model.bind "change:#{name}", ->
+ el.val(model.get('name'))
+ el.on 'change', ->
+ attrs = {}
+ attrs[el.attr('name')] = el.val()
+ model.set attrs
+
+
+$.extend $.fn, extensions
Something went wrong with that request. Please try again.