All Questions
Tagged with model javascript
723
questions
195
votes
11
answers
435k
views
Accessing MVC's model property from Javascript
I have the following model which is wrapped in my view model
public class FloorPlanSettingsModel
{
public int Id { get; set; }
public int? MainFloorPlanId { get; set; }
public string ...
114
votes
3
answers
257k
views
How to load json into my angular.js ng-model?
I have what I think is probably a very obvious question, but I couldn't find an answer anywhere.
I am just trying to load some JSON data from my server into the client. Right now, I am using JQuery ...
72
votes
3
answers
23k
views
Where Should Model State Be Stored In Angular.js
I'm finding Angular's use of models confusing. Angular seems to take the approach that a model can be anything you like - I.E. Angular does not include an explicit model class and you can use vanilla ...
30
votes
1
answer
32k
views
ES6 Classes for Data Models
I'm trying to use ES6 Classes to construct data models (from a MySQL database) in an API that I'm building. I prefer not using an ORM/ODM library, as this will be a very basic, simple API. But, I'm ...
29
votes
5
answers
9k
views
Best way to make one model 'selected' in a Backbone.js collection?
I have a collection of models in my Backbone.js application.
It's a list of items that you can hover over with the mouse or navigate around with the keyboard.
If the mouse is hovering, or if the ...
29
votes
1
answer
4k
views
Re-using Backbone.js models on the server side with Node.js and Websockets
I've been working my way through:
http://blog.andyet.com/2011/02/15/re-using-backbonejs-models-on-the-server-with-node
I have a few questions about sharing models server-side and a few questions ...
27
votes
4
answers
18k
views
Backbone change model of View
I am fairly new to Backbone and have the following question:
I have a collection of models.
I have a collection view displaying tabs (with a view for each model in the collection).
I have a view ...
25
votes
3
answers
25k
views
Sequelize: seed with associations
I have 2 models, Courses and Videos, for example. And Courses has many Videos.
// course.js
'use strict';
module.exports = (sequelize, DataTypes) => {
const Course = sequelize.define('Course', {...
19
votes
4
answers
8k
views
automatically generate javascript object model from c# object
Looking for existing, proven, solutions for quickly generating a client-side javascript object model that represents an existing c# object. I imagine there is a T4 template or some other approach out ...
18
votes
6
answers
14k
views
Is Backbone.js really an MVC? [closed]
backbone.js has been spoken of as an MVC framework for Javascript. But is it?
Here is the description of the model, from http://documentcloud.github.com/backbone/
Models are the heart of any ...
18
votes
7
answers
45k
views
Access a Model property in a javascript file?
Is it possible to access a Model property in an external Javascript file?
e.g. In "somescript.js" file
var currency = '@Model.Currency';
alert(currency);
On my View
<script src="../../Scripts/...
17
votes
1
answer
7k
views
does Backbone.Models this.get() copy an entire array or point to the same array in memory
Person = Backbone.Model.extend({
defaults: {
name: 'Fetus',
age: 0,
children: []
},
initialize: function(){
alert("Welcome to ...
16
votes
2
answers
8k
views
Passing MVC Model Data to Client-side TypeScript Code
When using MVC, I sometimes pass the server's model data to the client-side JavaScript by using Razor injected into the JavaScript, as follows:
<script type="text/javascript">
var ...
16
votes
3
answers
11k
views
ExtJS - How to use Proxy, Model? How are they related?
I've been trying to learn to work with Models and Stores. But the proxy bit is confusing me a lot. So I'm going to list out my understanding here - please point out the gaps in my understanding.
My ...
15
votes
1
answer
15k
views
Backbone.js model.destroy() not sending DELETE request
I've been trying for days to get this working and I just cannot figure out why when I have my view to destroy a model which belongs to a collection (which properly has a url attribute for the ...
15
votes
5
answers
3k
views
How to create a normal sails model without being in the models folder
So,
I'm in the middle of implementing a plugin api for my application, and the plugins can have their own models, imagine this.
SimplePlugin = {
pluginName: 'simple',
pluginConfig: {},
...
14
votes
4
answers
27k
views
ExtJS 4: cloning stores
I'm trying to figure out how to clone an Ext.data.Store without keeping the old reference.
Let me explain better with some code. Here's the source store:
var source = Ext.create ('Ext.data.Store', {
...
13
votes
4
answers
9k
views
backbone.js - handling model relationships in a RESTful way
I'm using backbone.js
For example, let's suppose we have a "products" model and a "categories" model which have a many-to-many relationship. In one of my views, say I need to retrieve a list of all ...
12
votes
3
answers
18k
views
For Loop over Backbone Collection
Fairly new to backbone, so this is a really basic question. I have a Backbone collection passed into a function and I can prove that it has been passed and that the models in the collection have ids.
...
12
votes
2
answers
1k
views
Does it make sense to initialize models from the DOM in backbone.js?
backbone.js relies on restful applications to initialize models, but what about progressive enhancement? The data is already in the dom (or some of it), so should my models still make calls the the ...
11
votes
1
answer
16k
views
TypeScript how to set types for accumulated Value and initialValue on Reduce function on an array
I have the current code running on typescriptlang.org (typescript playground)
I have read up on the importance of types in typeScript and how to use them in functions. However i'm struggling with ...
10
votes
3
answers
1k
views
Backbone: Use Model's Data and Functions in View
I'm fairly new to Backbone and was wondering how to access a model's data and functions from a view that injects the model as a dependency.
My model looks like this:
countries.coffee
define [
'...
9
votes
2
answers
9k
views
Extend Ext.data.Model (add fields dynamically)
I extended an existing Model by adding fields using the prototype. Everything works fine, the data can be received from the server side and can be used on client side. But, when I now update my data ...
8
votes
1
answer
8k
views
Get the model type for a passed in backbone.js model instance
How do I retrieve the model name for a backbone.js model instance?
For example:
var Topic = Backbone.Model.extend({
})
var topic = new Topic({ type: 'question' })
var doSomethingWithTopic = ...
8
votes
4
answers
15k
views
Object oriented approach with AngularJS
It seems that Angular does not provide a built-in solution to define class instances with properties and methods and that it's up the developer to build this.
What is the best practice to do this in ...
8
votes
2
answers
15k
views
How do I handle animated models in Three.js?
I have a basic question about Three.js. I've googled but didn't find anything useful...
How do I handle animated models in Three.js? I know how to import .js files, and I have an animated cube ...
7
votes
2
answers
162
views
Is it correct to pass model reference directly to HTML element?
Is it correct to pass model reference directly to HTML element?
window.car = {
color: "blue",
maxSpeed: 200
}
var element = $("<div>");
car.$element = element;
element[0]._model = car;
$...
7
votes
2
answers
2k
views
Model validation fails in Sails.js
I tested the following Employee.js model in Sails.js and I found something that seems hard for me to understand.
When the form for creating a new Employee is posted, I got the following errors with ...
6
votes
2
answers
7k
views
convert javascript object to model in backbone
is there any way to parse object in javascript to model in Backbone.js
here is my object
6
votes
2
answers
7k
views
Do you initialize your Backbone views from within a model or elsewhere?
Do you initialize your Backbone views from within a model or elsewhere?
I'm trying to figure out what the best way to organize model/views. Does it make sense to have your models initialize the ...
6
votes
2
answers
3k
views
Meteor display array inside a collection
I want create a posts model, with tags, and be able to display all tags for each post. You know a best way to do it ??
I tried this
<template name='postsLists'>
{{#each post}}
{{> ...
6
votes
3
answers
20k
views
create models in expressjs
I have an express app that gets its data from an external API
api.com/companies (GET, POST)
api.com/companies/id (GET, PUT)
I want to create a model to make the code easier to maintain as you can ...
6
votes
2
answers
4k
views
Three.js what causes shadow acne and how to fix it
In order to let all shadows be rendered, I set shadow.camera.top / bottom / left / right to the directional light (casting shadow), but it causes shadow acne.
I try to use shadow.bias but still not ...
6
votes
2
answers
2k
views
Extend built-in User model to support more properties and behaviors in loopback
I want a model to represent a profile in my loopback app. But, the built-in User model found in loopback only have the following properties
username
password
realm
emailVerified
What is the best way ...
6
votes
1
answer
6k
views
Mapping JSON responses to model classes in Vue.js
Is there a best practice or de-facto library for Vue.js when it comes to mapping JSON API responses to "real" javascript Model objects? Coming from iOS Development, there are excellent libraries like ...
6
votes
1
answer
1k
views
Backbone relational events not firing?
class TheModel extends Backbone.RelationalModel
relations:[
type: Backbone.HasMany
key: 'subModels'
relatedModel: SubModel
collectionType: SubModels
...
5
votes
2
answers
4k
views
Backbone filtering
If I have a Backbone collection and want to create a copy of that collection with certain entries filtered out, how can I do that while keeping the copied instance as a Backbone.Collection?
Example:
...
5
votes
3
answers
983
views
Single Object Model for AngularJS
I am experimenting few best practices in AngularJS specially on designing model. One true power in my opinion in AngularJS is
'When model changes view gets updated & vice versa'
. That leads ...
5
votes
1
answer
2k
views
Get array from model to view
In my model I have one int object and a boolean array:
public class mymodel
{
public int Round { get; set; }
public Boolean[] lstLabs { get; set; }
}
In my view I write this :
<script type="...
5
votes
1
answer
6k
views
Updating Model from form in Backbone
I am creating a simple application using Backbone and Laravel to manage bookings, and I'm working on a simple form to update user data for the currently signed in user.
I was wondering, is there a ...
5
votes
1
answer
2k
views
Ember.js - Call parent model hook to load data for child
I have a master/detail view in Ember. If i am calling the detail page directly, the model hook of the detail page needs the model(data) from the parent(master). The detail model hook is called - whats ...
5
votes
2
answers
5k
views
Sencha Touch 2 - JSONP proxy help, template always has null for values
I'm having trouble getting actual data to show up in a Sencha Touch 2 list. The list should be populated by a JSONP response, and I expect 2 rows to show up. Instead, I get one row with 'null at ...
5
votes
2
answers
3k
views
Backbone model validation
I have encountered a strange behaviour of the model validation in Backbone.js.
When a model is first created, like
var foo = new Foo({
bar: 42
});
Backbone invokes foo.set() passing as a ...
5
votes
1
answer
20k
views
how to create a model in javascript to make sure all properties does exists
i wonder how to create models in javascript ?
example Object user: should have these properties [name,username,password], and no other properties should be there.
now i want to send in any value it ...
5
votes
2
answers
8k
views
How to ignore null fields in ExtJS data models?
My question is very long... So, be patient :)
I'm working with models in ExtJS 4, but I'm having some problems with the associations, so I created a function to perform the automatic model creation ...
5
votes
1
answer
627
views
Ember Models and SQL - Joining tables on server or via Ember relationships?
With Ember, you can find a number of tutorials on building blogs and to do lists, but there doesn't seem to be much on anything that requires more complex models. I'm looking for a little more ...
5
votes
1
answer
948
views
EmberJS no model was found but it's there
I'm writing an ember-cli app. I have the following model:
// app/models/school.js
export default DS.Model.extend({
name: DS.attr('string', { defaultValue: '' })
});
It was generated using an ember ...
4
votes
1
answer
6k
views
BackboneJS best way to rearrange models in a collection while maintaining 0-indexed ordinal property for each model
I have a problem I'm playing with here, I have a collection of BackboneJS models, each model has a 'ordinal' property that tracks its order in the collection.
Here is my play-data
var ...
4
votes
1
answer
17k
views
Adding new models to a backbone collection, not replace
I am trying to add new models to a collection (i'm not saving to the server this time, just doing this in memory). I have the code below:
$(function () {
//Model
var Story = Backbone.Model.extend({
...
4
votes
1
answer
993
views
What can I use Backbone JS's Models for exactly? Is this too far?
I have a question regarding Backbone JS's Models. I've already delved into Backbone JS quite a bit the last few days. I am understanding it now (and thanks to Stackoverflow, I have understood further ...