Comments (4)
Are you using "data" for anything? Could you pass the id
as part of data, then set it on your module in initialize
, then read it on dispose
?
from knockout-amd-helpers.
Thanks for the response.
I'm using data
already to pass global init data into the module.
I have module config details maintained within a config file - including details needed for the amd plugin + additional details(for ex - id, storage key).
The idea is to make the module capable of loading/saving session data from/to local browser storage on initialize/dispose using a key(which comes from configuration).
Also, I find myself throwing in console.log
statements for view model level debugging. The 'knockoutJS context debugger' in chrome is unable to drill down to the individual view model details. This might be an unrelated question, thought I'd just mention it to get your feedback.
from knockout-amd-helpers.
Hello- There is not a great way within the module JavaScript code to reach up to the parent and read the moduleInfo
object unless you were to require your "app" level module from within your child module, which I personally wouldn't really want to do.
My thought would be to find a way to pass it in with the data. You have some flexibility:
You can include it with your data like:
this.moduleInfo=ko.observable(
{ data: {
something: "test",
id: "moduleId"
},
name: "modulevm",
template: "moduleTmpl"
}
);
otherwise, if your "data" is already separate, you can actually pass an array to data and make initialize
take multiple arguments like:
this.moduleInfo=ko.observable(
{ data: [{ something: "test" }, "myModuleId" ],
name: "modulevm",
template: "moduleTmpl"
}
);
Then, have your initialize
look like:
this.initialize = function(data, moduleId) {
this.moduleId = moduleId;
};
I think that this last option might be a good choice for your scenario.
from knockout-amd-helpers.
Thanks for the suggestions.
from knockout-amd-helpers.
Related Issues (20)
- AfterRender not firing when module is initialized with a null observable HOT 2
- Getting the reference to the bound element HOT 10
- module and template loaders don't work with require.config moduleIDs packages HOT 12
- API available in bonded module needs to be called after template finishes rendering HOT 2
- Working with Typescript AMD Modules HOT 2
- [Request] Option to require additional files by convention HOT 1
- Provide simple way to load external templates from within custom bindings HOT 1
- afterRender still fires only for the first template when using external templates with requirejs/text HOT 2
- publish NuGet package for v.0.7.3 HOT 1
- Module Binding: require() for the template source should not have to wait until the module is downloaded
- Passing data from Tempate to Module HOT 2
- template binding with 'with' doesn't work HOT 4
- beforeRemove callback is not firing for template binding HOT 5
- Ready to use KO module using requirejs "map" HOT 2
- Passing markup into modules HOT 14
- Knockout-amd-helpers does not play well with r.js namespacing HOT 3
- renderTemplateSource produces an empty string HOT 3
- Dynamically assigning a template path in renderTemplate() HOT 2
- not working with webpack very well. HOT 2
- knockout-amd-helpers need new typings
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from knockout-amd-helpers.