Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for ender.js #322

Merged
merged 1 commit into from Apr 18, 2011
Merged

support for ender.js #322

merged 1 commit into from Apr 18, 2011

Conversation

dvv
Copy link
Contributor

@dvv dvv commented Apr 15, 2011

Please, consider applying.
TIA,
--Vladimir

@jashkenas
Copy link
Owner

Compatibility with Ender.js is usually defined on the Ender side of things, and not the libraries Ender targets. Just being a CommonJS-compliant module should be good enough for this.

@jashkenas jashkenas closed this Apr 15, 2011
@dvv
Copy link
Contributor Author

dvv commented Apr 15, 2011

Do I get this right that you say any library which provides or will provide the basis for backbone must implement $.browser.msie, jQuery or Zepto and _?

@jashkenas
Copy link
Owner

Sorry, didn't look at the commit closely enough -- you're quite right.

@jashkenas jashkenas reopened this Apr 15, 2011
@jashkenas jashkenas merged commit 94edc63 into jashkenas:master Apr 18, 2011
@jashkenas
Copy link
Owner

Thanks, merged to master with some implementation tweaks at: 4070364

@dvv
Copy link
Contributor Author

dvv commented Apr 18, 2011

Thanks

@dvv
Copy link
Contributor Author

dvv commented Apr 18, 2011

Am sorry, in my code I didn't use Backbone.sync, but we need to normalize $.ajax. I see the following differencies:
jQuery.ajax: .type is verb, .dataType is expected format, no .headers
ender.ajax: .method is verb, .type is expected format, .headers (no "before" hooks), no .contentType (.headers should do)

@samuelclay
Copy link
Contributor

I'm pulling out Ender.js support for the time being until the signatures of the ajax methods are normalized to what jQuery and Zepto use. There are also other areas where Ender needs to be tested with Backbone. It's not fully baked support yet, so it's better if we remove the Ender reference until the tests are in. Removed in 1d4484d

@dvv
Copy link
Contributor Author

dvv commented Apr 22, 2011

np. i pinged ender.js guys a couple of days ago -- they added before to mimick onbeforesend hook. What about further normalization (completely different meaning to type options key) -- i think it's to be done in Backbone.sync.

@dvv
Copy link
Contributor Author

dvv commented Apr 28, 2011

@samuelclay: can you at least leave var $ = root.jQuery ... || root.$? This won't harm existing stuff, still will allow to use custom $s. TIA

@ded
Copy link

ded commented May 10, 2011

argh. stupid jQuery signature is wrong. type should be the data type, not the method -- we'll see what we can do on Reqwest side.

@benekastah
Copy link

@ded What's the status of reqwest on this? Is there a clear path as far as the changes that should be made to reqwest? I would be happy to issue a pull request for whatever those changes are, if a decision can be made.

@rvagg
Copy link

rvagg commented Jan 6, 2012

Reqwest 0.4.0 brings a compat mode so Ender can now speak the strange alien language of jQuery/Zepto.

$.ajax.compat({
  url: 'path/to/data.json?foo=bar',
  dataType: 'json',
  contentType: 'application/json',
  success: function() {
    // whatever
  }
});

or to install this as the default mode then put this at the top of your code somewhere:

$.ajax.compat && $.ender({ ajax: $.ajax.compat });

See the readme or source for gory details.

A Backbone user may want to confirm that all is well in the Backbone/Ender love nest?

For best compatibility it may be good to do this in Backbone.sync():

    return ($.ajax.compat || $.ajax)(_.extend(params, options));

or, better still create a reference to it at init so it's not checked each time:

  var $ = root.jQuery || root.Zepto || root.ender;
  var $ajax = $.ender && $.ajax && $.ajax.compat ? $.ajax.compat : $.ajax;

and use $ajax in Backbone.sync().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants