GithubHelp home page GithubHelp logo

Comments (5)

DrewDahlman avatar DrewDahlman commented on May 26, 2024

Ah this is due to the fillers being removed and then added again based on new layout. Might want to rebind on callback complete.

Sent from my iPhone

On Dec 24, 2014, at 7:33 PM, Seyi [email protected] wrote:

@DrewDahlman Hi, I have a Mason grid and I have noticed that the filler elements have their events unbound, in this case click events, once they are rendered in the DOM. The promoted elements are fine, I assume they are untouched by the implementation that manipulates the filler elements. Any ideas why this is happening?


Reply to this email directly or view it on GitHub.

from mason.

theseyi avatar theseyi commented on May 26, 2024

Hi @DrewDahlman, thanks for your response. Is it possible to configure Mason to re-delegate events once it's added items in the filler_blocks array, or when the unbinding happens. I'm using Mason with Backbone/Marionette, so I need to maintain reference between the filler element and it's corresponding view. Thanks.

from mason.

DrewDahlman avatar DrewDahlman commented on May 26, 2024

Hmm there is the complete callback that will fire when mason completes layout, you could maybe do it there.

Mind posting a bit of code for when you're creating the views based off of the filler blocks? I want to make sure I am understanding correctly

Sent from my iPhone

On Dec 26, 2014, at 10:15 AM, Seyi [email protected] wrote:

Hi @DrewDahlman, thanks for your response. Is it possible to configure Mason to re-delegate events once it's added items in the filler_blocks array, or when the unbinding happens. I'm using Mason with Backbone/Marionette, so I need to maintain reference between the filler element and it's corresponding view. Thanks.


Reply to this email directly or view it on GitHub.

from mason.

theseyi avatar theseyi commented on May 26, 2024

Thanks @DrewDahlman , I did try using the complete callback, however, since the reference between the view and it's DOM element has been severed, I can't quickly just rebind the view.I tried this in the callback:

        onRender: function () {
            $('.posts', this.el).mason({
                itemSelector:  '.prime-tile',
                ratio:         1,
                sizes:         [
                    [1, 1]
                ],
                columns:       [
                    [0, 1680, 8]
                ],
                promoted:      [
                    [1, 2, 'recommended-tall'],
                    [2, 2, 'recommended-promoted'],
                    [2, 1, 'recommended-wide']
                ],
                filler:        {
                    itemSelector:   '.filler-tile',
                    'filler_class': 'recommended-filler'
                },
                gutter:        0,
                layout:        'fixed',
                randomFillers: true
            }, function () {
                this.children.each(function (view) {
                    view.$el.click(_.bind(view.onTileClicked, view));
                });
                this.revealTiles();
            }.bind(this));
        }, ...

If you are familiar with Backbone.Marionette, I'm using a CompositeView to create the grid. In essence, the blocks are created by looping over some data models and creating a block view, then appending that to the main container. Each view has an $el property that is a reference to the view's DOM element, which binds that view to the specific DOM element. The CompositeView has an appendHtml method I can override to append my blocks into specific containers, like so:

        appendHtml: function (collectionView, itemView, index) {
            if (itemView.model.get('displayType') === 'filler') {
                itemView.$el.addClass('filler-tile');
                collectionView.$('div.filler-bucket').append(itemView.el);
            } else {
                switch (itemView.model.get('displayType')) {
                    case 'promoted':
                        itemView.$el.addClass('prime-tile recommended-promoted');
                        break;
                    case 'twice-wide':
                        itemView.$el.addClass('prime-tile recommended-wide');
                        break;
                    case 'twice-tall':
                        itemView.$el.addClass('prime-tile recommended-tall');
                        break;
                    default :
                        itemView.$el.addClass('prime-tile');
                        break;
                }
                collectionView.$('div.posts').append(itemView.el);
            }
        },

from mason.

theseyi avatar theseyi commented on May 26, 2024

Fixed in pull request: #39

from mason.

Related Issues (20)

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.