Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 10 21:38
    mainstreetmark commented #3631
  • Jun 18 11:39
    alexone077 commented #2200
  • Jun 18 11:39
    alexone077 commented #2200
  • Jun 06 13:18
    paulfalgout locked #3670
  • Jun 06 12:49
    thapaphon21731 commented #3670
  • Jun 06 12:42
    paulfalgout closed #3671
  • Jun 06 12:42
    paulfalgout closed #3670
  • Jun 06 11:39
    thapaphon21731 opened #3671
  • Jun 06 11:35
    coveralls commented #3670
  • Jun 06 11:33
    thapaphon21731 opened #3670
  • May 23 06:10

    paulfalgout on next

    bug fix for addChildView (compare)

  • May 23 06:10
    paulfalgout closed #3669
  • May 14 05:00
    paulfalgout milestoned #3669
  • May 14 04:59
    paulfalgout labeled #3669
  • May 14 04:59
    paulfalgout edited #3669
  • May 13 19:43
    coveralls commented #3669
  • May 13 19:41
    coveralls commented #3669
  • May 13 19:39
    taburetkin ready_for_review #3669
  • May 13 19:38
    taburetkin edited #3669
  • May 13 19:38
    taburetkin reopened #3669
dimtabu
@taburetkin
i created a mixin for marionette view based on 3d party popperjs lib
it shows any given view as popover/tooltip on mouseover or click based on options.
some kind of reusable thing in application.
i did it. i just not sure is it good enough
because of popperjs specifics
Wes Vetter
@wesvetter
ahh, you're trying to put a Mn View inside the popper?
dimtabu
@taburetkin
yeah
not trying :) i did it
Wes Vetter
@wesvetter
what's the use-case for needing a fully-fledged Mn View and not just a plain-text/html string?
dimtabu
@taburetkin
ah
i can show with screen, its hard to explain
image.png
Wes Vetter
@wesvetter
I see. Yeah, that'd be nice to encapsulate in a regular Mn view
dimtabu
@taburetkin
hover/click on desktop, click on touch device. - depends on use case
but its laways to provide some additional information in well formed manner which is not necessary in the short view
and the well formed view is not all
there can be active interface elements ready for user interaction, so, go through just template strings is not the case
Wes Vetter
@wesvetter
my initial thought would be to make some sort of Mn Behavior that 1.) creates a popover with an empty Region in it, and 2.) emits some lifecycle and status events for popover. Then you could hook into these events to show complex child views. Something like:
class Promotion extends Marionette.View
  template: _.template '''
    <%- name %>
    <%- price %>
    <button data-popover>
        Details
    </button>
    <button class="js-buy-item">Buy</button>
  '''

  behaviors: [ Popover ]

  onPopoverInitialize: (popover) ->
    popover.region.show new DetailsView(model: @model)
dimtabu
@taburetkin
this solution is not acceptable in some cases and is not as universal as it can be.
behavior or mixin - this is does not matter.
the important thing how to render content view.
i prefer to take out region from behavior/mixin just to be able create a standalone versions of any tooltip/popover.
in case of just modal view its pretty trivial.
the main goal of using popperjs for popover or tooltips is ability to put content element in a correct place and visually stick with the reference
the variants of possible layouts is very big and it seems that popperjs has solved all possible variants and works well
the mechanic of popperjs is that you have to provide some content dom element which must be present in the dom
and this is thing i've woried about: i can render content view at least by two different ways: just call render or use stand alone region with show
currently i am stick with simple view.$el.appendTo(document.body)';view.render;
and this is seems to me wrong
i believe its better to render and attach standalone view in some region.
and now we are comming close to question i really want to ask
if i create a region in the dom and render in it a popoverview and popperjs will detach view.el and reattach it to correct place, is it safe enough to use regions?
dimtabu
@taburetkin

@paulfalgout Paul, in the region.show view's attach events happens after view's render?

before:render
render
before:attach
attach

or they are surrounding render events?

before:attach
render
before:render
attach
Paul Falgout
@paulfalgout
depends on when the render occurs
typically it'll render everything before both attach events, but that's not guaranteed

For one, there's no reason you couldn't do this:

onBeforeAttach() {
  this.render();
}

No doubt you'd shouldn't do that, but it certainly can occur.

dimtabu
@taburetkin
i mean the default behavior in typical render lifecycle
without any black magic from the dev side
so, the first one - attach events after all render events. ok
ah, collectionView's childView has same logic? render events then attach events ?
Paul Falgout
@paulfalgout
nothing will attempt to attach a view that is not already rendered
dimtabu
@taburetkin
ok
dimtabu
@taburetkin

why this is work

    childViewTriggers: {
        'control:change':'control:change'
    },
    onControlChange() {
        console.log('ok!');
    },

and this is not work?

    childViewEvents: {
        'control:change'() {
            console.log('ok');    
        }
    },

i believe i did something interesting but in general i think that both should work, but its not :-/

Paul Falgout
@paulfalgout
It does work. If it's not working it isn't the childViewEvents that isn't working. https://jsfiddle.net/c621xa8g/
dimtabu
@taburetkin
i wonder what i did
Allan Bazinet
@bazineta
Is that second syntax supposed to work?
i.e., the use of () instead of : after control:change?
Allan Bazinet
@bazineta
Well, per the fiddle, apparently so. Must be something I glossed over at some point.
dimtabu
@taburetkin
its an es6 things
as Paul said and i was pretty sure before both things should work.
but in my case childViewEvents didnt. now i have to find out what exactly i did which broke this behavior
dimtabu
@taburetkin
finally, i found out.
that was because i pass options with defined childViewEvents to the view constructor and that overrides my prototype childViewEvents, so, triggers still works and childViewEvents just has another handlers. :-/
now, i am thinking how to do this in more gentle way.
i still need pass some childViewEvents but without wiping prototype one.
dimtabu
@taburetkin
hard times.
i have some strange thing i can not explain to myself
i have some universal trigger which invokes triggerMethod or trigger on given context.
and occasionally it throws an error some where in the deep of backbone
dimtabu
@taburetkin

Uncaught (in promise) TypeError: callback.apply is not a function
it happens on some internal backbone eventsapi method

  // Reduces the event callbacks into a map of `{event: onceWrapper}`.
  // `offer` unbinds the `onceWrapper` after it has been called.
  var onceMap = function(map, name, callback, offer)

i believe the error happens of course because of me, something wrong with context events hash and i will find the error, somewhen.
but thing i realy dont understand is in this piece of code which exactly throws an error
its a part of my trigger function

.....
    if (context.triggerMethod) {
        try {
            return context.triggerMethod(event, ...args);
        } catch (e) {
            return context.triggerMethod(event, ...args);
        }
    } else {
        return context.trigger(event, ...args)
    }

as you can see, there is a some kind of dark magic with try catch block.
the context.triggerMethod(event, ...args); in try block effectively throws an exception mentioned above.
i expect that i will see the error anyway because i do same call in catch block and second exception should happens, but its not.
on the second call everything is fine.
just... wtf?

dimtabu
@taburetkin
i've found the error. incorrect use of Backbone.Events api
i was thought that i can do this this.once('resolved','destroy'), don't know why i decided that backbone event allow string literals for callbacks
Nasir Hussain
@nasirhjafri
Any python open source projects here?
Paul Falgout
@paulfalgout
nope
Schlaefer
@Schlaefer
Hi, is somebody working on a typescript definition file for marionette 4?
Paul Falgout
@paulfalgout
I'm not aware. I believe the most updated definition is via https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/backbone.marionette/index.d.ts and it's on 3.3.
Schlaefer
@Schlaefer
Thanks, that's the one I'm using a the moment, which still works surprisingly well with 4.x. - I made PR there in the past for missing definitions, but I don't feel comfortable to bump the version string and maybe f' things up for everybody.
Martin Lundberg
@marlun
I'm having some problems with setting up a marionette object with channelName and radioRequests but later when I do channel.request('foo') there seem to be no one listening. I'm having a feeling it has something to do with different Backbone.Radio instances between what is setup by Marionette and what I get when I do const Radio = require('backbone.radio') but not sure. Any tips? :)
Paul Falgout
@paulfalgout
npm ls backbone.radio maybe to check if you have more than one
Martin Lundberg
@marlun
I have it as a dependency to marionette and as a project dependency, both is 2.0.0 and marionette is 3.5.1. The weird thing is I have another project that I've matched the versions on and there it works. So I'm probably doing something I shouldn't where it doesn't work.
Paul Falgout
@paulfalgout
You can also try Radio.tuneIt('channelName') to see if you're getting what's expected and Radio.DEBUG = true will warn of unhandled requests
Martin Lundberg
@marlun
Well, after all this work all that was needed was an upgrade of marionette and backbone.radio. I also had to spell correctly :) Thanks for the help!