-
Notifications
You must be signed in to change notification settings - Fork 145
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
Starting a module that will add it's own html #186
Comments
There's several themes here, you are talking about routing requests and rendering specific pages based on that. For example, the menu should have links like var contentEl = document.querySelector('#content');
where the HTML could either come from an AJAX call or you already have it locally. If you want to avoid the router, I suppose you could have 2 modules instead that do something similar
You probably want a helper service too, to help with setting html:
Then in the top module:
And in the content module JS:
At least that's the rough idea. |
Thank you, it's exactly what I wanted to do. |
I have been wondering about starting modules from other modules. Until I saw this issue, I was doing: element.appendChild(newElement)
context.application.start(newElement) However the I have created a DOM service which appends the element and starts it, but I am having trouble testing the module because To keep my tests flexible, I want to test that the element gets appended and module started, so ideally I'd like to keep the DOM service in the I guess this is approach is a bit more like an integration test, but it seems appropriate. So I suppose my question is, is there any way to stub the application object in a module test? |
Yeah, you shouldn't be using |
OK, cool. So how are you testing that in the module test? For example, let's say I have a DOM service with an append method: append: function (element, container) {
container.append(element)
application.start(element)
} In my module: someMethod: function (newElement) {
domService.append(newElement, element)
} In my module test: element = document.createElement('div')
context = new Box.Application.TestServiceProvider(['dom'])
context.getElement = function () { return element }
module = Box.Application.getModuleForTest('conversation', context)
module.init()
test('someMethod appends the new element', function (assert) {
var newElement = document.createElement('div')
module.someMethod(newElement)
assert.equal(element.firstChild, newElement)
}) This throws an exception that I need to stub out I could stub the DOM service and its |
First thing I see is Since technically you don't want to test the child module's functionality, merely that it was 'started', you could use The way that the TestServiceProvider works is that it passes itself in as an |
Hi, is it possible to start a module from another module that will add it's own html inside a div?
For example i have a basic html structure
<div data-module="top"></div>
<div id="content"></div>
I want in #content to be able to start different modules based for example on a menu in top module.
So, top module will have to start another module (home or about-us) based on selected menu and that module will have to add it's html
<div data-module="home"></div>
or<div data-module="about-us"></div>
inside #contentor do i have to append the html of the module i want to load inside #content from top module before starting it ?
Thanks
The text was updated successfully, but these errors were encountered: