Skip to content

Using Alloy model and collection without a view data binding #13556

Answered by m1ga
beppo-ivel asked this question in Q&A
Discussion options

You must be logged in to vote

I like that you put an example in there but I've removed some parts to make it easier to debug/solve 😄 Feel free to add your location stuff back in (since that has nothing todo with the model I left it out)

Model and lib is the same.

<Alloy>
  <Collection src="random"/>
	<Window class="container" onClick="doClick" />
</Alloy>
let Util = require('/util');

function doClick(e) {
	Util.record(e);
	let models = Alloy.Collections.random;
	models.fetch();
	console.log(JSON.stringify(models));
}


$.index.open();

click anywhere and it will output the model. I've registered the Collection in the XML file and do a fetch().

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@beppo-ivel
Comment options

@m1ga
Comment options

m1ga Sep 2, 2022
Collaborator

@beppo-ivel
Comment options

Answer selected by beppo-ivel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants