GithubHelp home page GithubHelp logo

Comments (7)

cjolif avatar cjolif commented on August 22, 2024

This is feasible by making sure the _TemplatedMixin that is used to load the view template is mixed into the view itself.

See a working tentative here: https://github.com/cjolif/dojox_application/commit/4a73a00d66174290a7e689e0039bf87f451bb12a

There might be cleaner way to achieve that though.

from dojox_application.

dmachi avatar dmachi commented on August 22, 2024

This used to be available as part of each view template I thought, but the mixins may have changed a little bit. The view classes can really do whatever is desired in this regard, so if someone extends a view and mixes in the appropriate templatedMixin logic, it should work fine. All that said, we should be careful about doing or encouraging more connections/events like this than are necessary. The convience tends to lead to too much work that could often be accomplished by less with event bubbling.

from dojox_application.

cjolif avatar cjolif commented on August 22, 2024

@dmachi this is indeed available part of the templating mechanism. But as of today the _TemplatedMixin instance is not mixed into the view and thus this is not working because it can't call the methods defined on the view. Even if I agree with you that this convenience might not always be good to use, I think it does have value in some cases? And as we are pretty close to getting it done, I think it would be worthwhile having it? If you agree I will work on a pull request that implements this (something probably very similar to the first draft I've linked above).

from dojox_application.

eric-wang avatar eric-wang commented on August 22, 2024

In dojox.app, it's recommend to use two ways to bind events:

  1. in view level, it's better to bind event by dojo.connect or dojo.on in the view's init(), and disconnect the event in view's destroy()
  2. in application level, it's better to create a controller to implement dojox.app.Controller and use the controller to bind events. for example:
    events = {
    "#buttonId :click": clickHandler,
    "div > .selected : click": selectedHandler
    };

in dojox.app.View class, render() method is independent on dojo, the widget created from template HTML should be a child of view, not mixin to view. view should be an object, not a widget. If the template is a jQuery HTML template, how to mixin the Jquery widget to view?

from dojox_application.

cjolif avatar cjolif commented on August 22, 2024

To answer:

in dojox.app.View class, render() method is independent on dojo, the widget created from template HTML should be
a child of view, not mixin to view. view should be an object, not a widget. If the template is a jQuery HTML template,
how to mixin the Jquery widget to view?

I agree. And actually what I'm mixing into the View is not a widget (_WidgetBase) this is a _TemplatedMixin "only"? But I agree there might be cleaner way to achieve that (see my initial comment). Do you have suggestions? Maybe a Dojo-specific View? But then how would it be triggered? I don't think the current mechanism allows one to extend View and plug his extension in?

from dojox_application.

dmachi avatar dmachi commented on August 22, 2024

View should be an instance of an object. It could simply generate html or it could render a template and attach functionality to that block of html. However, this is really at the conceptual level. We should make sure we don't depend on a dojox.app.View being there (or something extending that), but in practice most of our stuff probably will.

The template html for a view is not itself a widget, it is simply html that gets processed and placed by whatever view function is initializing it. This of course is free to ignore dojo, _Widgetbase, etc. However, for our views that use templates (most of them) I would expect to use _WidgetBase and _TemplatedMixin as base classes for the view. That is the "view" becomes a single dojo widget with the optional template being the content of that widget. If one were to include a jquery widget, it would either be a child of the view 'widget' (placed inside that view widgets html) or one could implement a View class with jquery itself.

All of this allows the simplest case to simply be a function or more complex objects like our view widget.

from dojox_application.

cjolif avatar cjolif commented on August 22, 2024

As of today I'm afraid we rely on View being here. But you are right we should probably make sure this is not the case anymore longer term. The Load controller should be more flexible and be able to load something else than the predefined View object.

I will try to work on a pull request with that in mind.

from dojox_application.

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.