Giter VIP home page Giter VIP logo

backbone.nativeview's People

Contributors

adamsea avatar akre54 avatar cloakedninjas avatar gaearon avatar jridgewell avatar radist2s avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

backbone.nativeview's Issues

InputEvents not binding correctly

Hi,

I have the following events hash:

events: {
  'blur input': 'someHandler
}

someHandler is never called> I think this may be because NativeView is relying on the Event propagating up the tree and checking whether selectors match on the eventTarget. Is the issue that InputEvents such as blur, input or change don't get propagated up to non-input nodes?

Would a better way to attach events be to query the view for the selector and use addEventListener on the Elements that returns rather than the Views root element?

Undelegating differs from jQuery

While messing with NativeView#undelegate I realized that it's only possible to undelegate using a selector when that selector matches exactly the string passed to delegate. It doesn't do matching or sub-selections.

Let's say you called view.delegate('click', '*') and then tried to view.undelegate('click', 'div'). Or view.delegate('click', 'h1, div'), or any sub-selector. Since the strings don't match, we wouldn't be able to undelegate for you. Selector strings don't work that way.

I'm tempted to say "screw it". Undelegating isn't that common of a use case. We'd have to implement the better part of Sizzle to get this behavior (or call matches over a querySelectorAll ElementList). Is it worth solving?

Backbone.$ is not a function

Hey, i am new to the 'MVC'-World but i would like to get my Hands on it.

I liked Backbone because im not dependent on an node-driven system and lame-old jQuery. On top of that, the syntax is great.

Anyways - like i said - i don't like to use jQuery and stumbled upon this great addition to Backbone.

So i include Backbone and after that Backbone.NativeView with script-tags.

<script src="../underscore.js"></script>
<script src="../backbone.js"></script>
<script src="../backbone.nativeview.js"></script>

Then i've tried to add my first view and it caused the following error 'Backbone.$ is not a function'

These are the lines that i've tried getting to work:

Backbone.View = Backbone.NativeView;
var MainView  = Backbone.View.extend();
var mainView  = new MainView();

var MainView = Backbone.NativeView.extend();
var mainView  = new MainView();

The call stack is as followed:

_.extend._ensureElement                 @   backbone.js:1105
Backbone.View                           @   backbone.js:1000
Backbone.NativeViewMixin.constructor    @   backbone.nativeview.js:61
child                                   @   backbone.js:1566
(anonymous function)                    @   script.js:83

It seems like he is trying to use the jQuery selector even though we defined our own $ Selector

$: function(selector) {
    return this.el.querySelectorAll(selector);
},

Am i doing something wrong, have i missunderstood something? In both cases, can someone please give me an advice.

Thanks a lot.

Btw: I am using Backbone.NativeView.js 0.3.2 and Backbone.js 1.1.2 with Underscore.js 1.8.2 in the latest Chrome

Exoskeleton + Browserify

I see this issue has come up a few times and in the tickets logged there's never really been a resolution. I've followed the instructions here (https://github.com/paulmillr/exoskeleton/wiki/Exoskeleton-without-jQuery) regarding how it should be handled from a Browserify / CommonJS perspective but I constantly get errors even when using aliasify.

The problem seems to be that Aliasify is not transforming anything in node_modules that we call as dependencies, so the reference to backbone inside your library never seems to get rewritten. The "recipe" in the link posted above, have you verified that it works and have a code example that I could pull?

I've logged a ticket with Aliasify:
benbria/aliasify#25

Should delegate align with jQuery behavior?

Related to akre54/chaplin/pull/4

There's some small inconsistencies between how jQuery and NativeView treat currentTarget and delegateTarget. I've put two ugly jsbin two illustrate this : one for jQuery and and one for NativeView, i think it comes from this jQuery bug

Basically, when using NativeView#delegate without selector, delegatedTarget is undefined, whilst in jQuery's case, it always equals currentTarget.

When used with a selector, currentTarget and delegatedTarget are swapped according to the implementation.

Not sure if it's possible or desirable to do something here. Thoughts?

Register on npm

This repo does not appear to be registered on NPM. Would you mind doing it? Putting Github repo url in package.json feels.. wrong.

events issues when no el is set

I'm not sure if this is NativeView or Backbone itself, so apologies in advance.

When defining an element that is in page el: '#some-element if the element doesn't exist, it is rightly set to null.

In the render function I can return early in this case, but any events that are defined are attached to the document as the element isn't there. This is causing issues and interruptions for the rest of the page.

What should I be doing in this case? I've tried using undelegateEvents to no effect, as they haven't been correctly delegated, and the code looks for this.el.

Working with require()'s

Im trying to load NativeView with require() but didnt see a guide on that. Being that everything I tried failed, can you please show how to do that?

I tried:

var Backbone = require('backbone'),
    _ = require('underscore'),
    NativeView = require('backbone.nativeview')

module.exports = Backbone.View.extend(Backbone.NativeViewMixin, {
var Backbone = require('backbone'),
    _ = require('underscore'),
    NativeView = require('backbone.nativeview')

module.exports = NativeView.extend({
var Backbone = require('backbone'),
    _ = require('underscore'),
    NativeView = require('backbone.nativeview')

module.exports = Backbone.NativeView.extend({

amongst other. While Backbone.View = NativeView works, this is for a library and I dont want to force NativeView to be global. When running tests, I'm getting:

 9) View Attach to:
     TypeError: Expecting a function in instanceof check, but got undefined
      at _.extend._setElement (node_modules/backbone/backbone.js:1253:40)
      at _.extend.setElement (node_modules/backbone/backbone.js:1242:12)
      at _.extend._ensureElement (node_modules/backbone/backbone.js:1322:14)
      at new Backbone.View (node_modules/backbone/backbone.js:1190:10)
      at Context.<anonymous> (tests/viewsTest.js:110:20)

Am I missing something? $el still exists.

Since Backbone.NativeView is not overriding _ensureElement, if I am using Backbone.NativeView directly, $el still exists. Which isn't a problem per say, but your documentation says otherwise.

Integrating into core backbonejs

Is there any plan to make NativeView part of backbonejs, as a sort of base view.

Would it make sense in the same occasion to deprecate the original Backbone.View, and point developers to some Backbone.$View instead in the case of jQuery?

bower install backbone.nativeview does not work

Hey I am not sure if this is normal, but in bower.json there is:

...
name: "backbone.nativeview",
...

When trying to install with bower install backbone.nativeview there is error "package not found". I was able to install it using bower install Backbone.NativeView though. I guess that maybe bower.json should be updated?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.