w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
trigger('click') doesn't work on anchors without an actuall link in the href ( js function in the href attrbute )
trigger('click') will only invoke attached event handlers; if you have JavaScript hrefs, they won't be triggered. You could try attaching regular click handlers to your links, or you could do something like this instead: var idFormat = /confirm_(d+)/; $('.confirm_btn').each(function() { var btn = $(this); var id = parseInt(idFormat.exec(btn.attr('id'))[1], 10); confirm_ajax(id); });

Categories : Javascript

changing href="example" to href="/example"
Have you tried using Replace to get that done? You could make it replace href=" >> href="/ String s = "href="example""; s.Replace("href="", "href="/"); That would return href="/example"

Categories : C#

BackBone Model - > Collection -> Model -> Update - does not trigger change on root model
I found out how to do it, just listen to 'data' change and trigger 'change' futher ServerInfoModel = Backbone.BaseRelationalModel.extend({ url: function () { return "/examples/serverInfo.json" }, setup: function () { var self= this; this.get('data').on('change', function () { self.trigger("change"); }); }, relations: [ { type: Backbone.HasMany, key: 'data', relatedModel: 'Data', collectionType: 'DataCollection', reverseRelation: { key: 'id', includeInJSON: 'id' } } ] }); Data = Backbone.BaseRelationalModel.extend({ }); DataCollection = Backbone.Collection.extend({ model: Data });

Categories : Javascript

updating the selection model and proxy model after insertion into a custom model in qt
Im sure you re trying to access your model data with the indexes given by the selection model. But selection model will return indexes relative to your view's model. And It is the proxy. So to access data of your model you must map it: e.g.: Consider you have a signal on current item change: connect( p_selectionModel, SIGNAL( currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(viewCurrentChanged(const QModelIndex &, const QModelIndex &))); On your slot: viewCurrentChanged(const QItemSelection & selected, const QItemSelection & deselected) selected will be a QModelIndex of your proxy. You could access to data through selected.data() .. But if your accessig this way: your_model->data( selected, role ) Your accessing your

Categories : Qt

cakephp - how to get the data from a model->model->model type relationship
The way you have it now you are basically just calling the PaypalTransaction model and request its find to return you all transactions in the last day. $this->FirstModel->SecondModel->ThirdModel doesn't mean to connect results from the first model to the second and then to the third, it's only a way to help you load the linked model instead of using $this->loadModel('ThirdModel') to load it. So you still need to place conditions according to what you want to do. For example, if it was just one model linked (assuming $this->Booking is set to a record) you could do: $this->Booking->PaypalTransaction->find('all', array( 'conditions' => array( 'PaypalTransaction.created >' => $oneDayAgo, 'PaypalTransaction.booking_id => $this->Booking-

Categories : PHP

Removing a belongsTo from a model shows warning Model 'x' is not associated with model 'y'
The message is been generated (most probably) because in your controller (check the ParentProductsController first) is something like $this->ParentProductsController->Product->find(); That association of models no longer exists because you wanted to get rid of it, so there's no way for ParentProducts to call Product. You need to change calls like that to ClassRegistry::init('the_name_of_the_model'); (in this case ClassRegistry::init('Product');) or load the model with $this->loadModel('Product'); Now, this only is necessary when you call models not related to the current controller. If you are calling Product->find from the ProductsController, there will be no error. Ok, that's the cause of the error. But now: I don't recommend you deleting the association. There

Categories : Cakephp

href="javascript:func()" vs href="#" onclick="javascript:func()"
If your JavaScript onclick event handler returns false, the scrolling won't occur. You can do it like this: <a href="#" onclick="expand(); return false;"> If your onclick handler does not return false, the href link will be followed. In the case of href="#", that means scroll to the top of the page.

Categories : Javascript

Find model returns undefined when trying to get the attribute of a model by first finding the model by another attribute?
Someone on irc gave me this answer. Then I modified it to make it work completely. Basically I should have used filtered. App.Office.filter( function(e){return e.get('unique_attribute_a') == 'foo'}).objectAt(0) Then I can get the attribute like: App.Office.filter( function(e){return e.get('unique_attribute_a') == 'foo'}).objectAt(0).get('attribute_b') See the code in jsbin. Does anyone know WHY filter works but find doesn't? They both return RecordArrays.

Categories : Ember Js

EmberJS: Load a teaser of a model for a list, full model for detail view
Here's my approach which eliminates the initial rendering delay. Is that what you meant by 'inelegant snap in'? // Load the light version of all subjects on page load App.ApplicationController = Em.Controller.extend({ init: function() { return App.Subject.find(); } }); // Fetch all our previously loaded subjects App.SubjectsRoute = Ember.Route.extend({ model: function() { return App.Subject.all(); } }); App.SubjectRoute = Ember.Route.extend({ // If we're loading the page directly to this route, do a normal find model: function(params) { return App.Subject.find(params.subject_id); }, setupController: function(controller, model) { // Show what details we have for this subject (e.g. the title) immediately controller.set("model", model); // Load full

Categories : Ember Js

Set nested resource controller model to child object of parent route model
You should be able to access the loans controller and its model from the child controller if you declare it as a dependency. Just add needs: 'loans' (with your actual loans route name) inside your product controller and then you can access the loans controller like this: this.get('controllers.loans'). You can read more here: http://emberjs.com/guides/controllers/dependencies-between-controllers/ Update to fully address original question From within the ProductRoute you should be able to access a parent model by doing this.modelFor('loan'). Make sure you use the actual route name declared in the Router.map.

Categories : Ember Js

Rails console return list of model if model's method returns false
Vehicle.all.select(&:auto?) Note that this is slow if there are a large number of vehicles, since they will all be loaded into ruby. It's more efficient therefore to do the test in SQL. E.g. if your #auto? method merely looks at an auto boolean field you could do this instead: Vehicle.where(auto: true) That also has the advantage of getting the result as a Relation rather than an Array, which allows you further refine the statement downstream before calling the database.

Categories : Ruby On Rails

get value in php
Build your menu in a loop: $menu_items = array( 'Home' => 'index.php', 'Resume' => 'resume.php' ); <ul id="navilist"> <?php foreach ( $menu_items as $title => $href ): ?> <li><a href="<?php echo $href; ?>" <?php echo activeMenuItem($href); ?>> <?php echo $title; ?> </a></li> <?php endforeach; ?> </ul>

Categories : PHP

Rails - AssociationTypeMismatch error with associating a model with multiple instances of another model
original_account_id is expecting an account object. you cannot set an id. credit_record.original_owner = account credit_record.account = account or credit_record.account_id = account.id Please rename your association to the following class CreditRecord < ActiveRecord::Base belongs_to :original_owner, :foreign_key => "account_id", :class_name => "Account" belongs_to :account

Categories : Ruby On Rails

Yii Project: How I can prevent from loading related model(child) for a (parent) model?
How do you know they are loaded with parent model? Have you checked the LogRoute? (Uncomment it in the config) 'log' => array( 'class' => 'CLogRouter', 'routes' => array( ... array( 'class' => 'CWebLogRoute', 'categories' => 'system.db.*', 'except' => 'system.db.ar.*', ), Related models are not loaded by default (if you haven't used with('relatedModel') method). Any related records will be lazy loaded when accessing the relation property the first time. http://www.yiiframework.com/forum/index.php/topic/7430-lazy-loading-of-many-many-relations/page_view_findpost_p_37674

Categories : PHP

(MVC4 - Razor) List of model in a model don't caught by the post method
The MyId should be correctly received with your existing code. The model binder can only match the value of inputs whose name have a matching property in the form. I.e. if you have an input like this <input name='bikes' ...> then your model should have a property Bikes so that the model binder can transfer the value from the input to the property. In your case you're creating input with dynamic names that doesn't have a matching property name. (NOTE: thei referes to the model you're using as the action parameter). The farthest you can go is giving a series of input elements the same name, i.e. several elements like <input name='categories' ...> and receive it in an array parameter like string[] categories or a model which has a property like string[] Categories {get;set;} In

Categories : C#

AngularJS ng-model form driven by ng-repeat over UI model description data how to?
I've just figured out one (but may be not the best?) way to achieve this myself.. see http://jsfiddle.net/vorburger/8CxRC/3/ - basically still based on my square bracket dynamic keys 'trick', but with some pre-processing: for (var i = 0; i < $scope.uimodel.length; i++) { var resolvedModelProperty = $scope.datamodel; var remainingPath = $scope.uimodel[i].model; while (remainingPath.indexOf('.') > -1) { var nextPathSlice = remainingPath.substr(0, remainingPath.indexOf('.')); resolvedModelProperty = resolvedModelProperty[nextPathSlice]; remainingPath = remainingPath.substr(remainingPath.indexOf('.') + 1); } $scope.uimodel[i].modelB = resolvedModelProperty; $scope.uimodel[i].modelL = remainingPath;

Categories : Javascript

Binding a ListBoxFor to a Model in MVC 3 and auto selecting multiple items using another Model
Model public class Admin { private List<int> _selectedEventIds; public List<int> SelectedEventIds { get { return _selectedEventIds ?? new List<int>(); } set { _selectedEventIds = value; } } private List<Events> _eventList; public MultiSelectList EventList { get { return new MultiSelectList( _listeFonctions, "EventId", // dataValueField "EventName" // dataTextField ); } } public Admin() { } public Admin(List<int> selectedEventIds, List<Events> eventList) { SelectedEven

Categories : Asp Net Mvc

ExtJs v4.2.1.883 - Ext.data.Store created with no model. The name does not correspond to a valid model
You're suffering from too acute digital reflexes. You've typed extends instead of extend in your model definition. extends is a reserved (yet unused) keyword of Javascript, so Ext had to use a less standard name... FYI, you don't need to enclose object property names in quotes, unless they contain special characters: { extend: '...' // that's ok }

Categories : Javascript

How to join model with attribute of other (related) model (plotting data from child)
You can join the tables using includes, arel = Level.includes(:user, :game) Then use appropriate query as you want to, arel = arel.group('user.email')

Categories : Ruby On Rails

Does mvc 4 application need another model to return aggregate data on an existing table and model
Depends on what you want to display to the user based on her selection' e. g. If you want to display TV name + its description then returning a list of TV model will make sense. If you are just going to display a list of TV names in combo box, then returning a list of string will suffice. Calling a new action make sense in both cases IMHO. EDIT: For 2 - I want to return a list of string - should I create a new data model for this, or add a method in the existing TV data model that returns a list of string? To expand on above query, since its not clear (at least I do not visualize it) from your question i will assume few things. Case 1: You are displaying a view say "TVSelection" to the user that does not contain list of TVModels. In this view you are expecting user to enter t

Categories : Asp Net Mvc

Edit attributes of a child model from the form representing parent model
Problem 1: delete adress on person deletion You can use post_delete signal to automatically delete the adress once your person is deleted. It's quite simple to use from django.db.models.signals import post_delete from web.programing.roxx.models import Person, Adress @receiver(post_delete, sender=Person, dispatch_uid="person_post_delete") def onPersonDelete(sender, instance, using, **kwargs): # be carefull, the instance doesn't exist anymore in the database adress_id = instance.business_Address.id if id != None: Adress.objects.filter(id=adress_id).delete() But this won't display the adress in the "Are you sure ?" message.. Problem 2: edit the adress in the person admin page For the moment, I don't see any solution simpler than building a custom form to edit Pers

Categories : Python

Backbone.js model.isValid() method not returning false for an invalid model
The problem here is that you're calling the { validate: true } option to your model.set method, then you're subsequently calling model.isValid(). When you call model.set with the validate option set to true, Backbone.js will not set the properties you pass unless they all pass validation. So, by the time you call model.isValid() the model has been changed back to the previous version (before the .set call). model.isValid() automatically calls the model.validate() method and passes the current attributes of the model to it. In your example, the values being passed to validate by the isValid method are the current (valid) attributes of your model. Because of this, isValid() is always going to validate to true. Which will cause you to never reach your else clause. The solution here is ins

Categories : Javascript

In Django, if I select_for_update() a particular model instance, will its related model instances be locked as well?
No. The example you give will make 2 queries: SELECT ••• FROM `mymodel` WHERE `mymodel`.`id` = 1 FOR UPDATE; SELECT ••• FROM `related_thing` WHERE `related_thing`.`id` = ?; Clearly only the first locks. However, if you use select_related() the single query would be: SELECT ••• FROM `mymodel` LEFT OUTER JOIN `related_thing` ON (`mymodel`.`related_thing_id` = `related_thing`.`id`) WHERE `mymodel`.`id` = 1 FOR UPDATE; In which case it would lock related_thing as well (at least in MySQL but it might be db dependent).

Categories : Django

Getting sum of column values from a related model when accessing another linked model in CakePHP
Since payments belong to a booking, a query for a booking should return an array of the associated payments. Use the afterFind callback function in the booking model to add up the payment totals and assign to a new element in the booking data structure. $results[0][$this->alias]['total_payments'] += $results[0][$this->alias]['Payment']['payment_amount']; http://book.cakephp.org/2.0/en/models/callback-methods.html#afterfind

Categories : Cakephp

Dynamically populating the dropdown menus in PHP Cake. Access Model from another Model?
Not sure if I get your question correct, but I think what you want is the following: User hasOne Student / Student belongs to User and Student hasOne Country / Country belongsTo Student (and the same for Lectureres) then from your UsersController you can do: $this->User->Student->Country->findCountiesByCountry(); hope that helps -- EDIT: if you want to want to use $role instead of Student/Lecturer you would have to do it like this: $this->User->{$role}->Country->findCountiesByCountry();

Categories : PHP

If you have external tasks that gather information about a model should it live in the model as a method?
If the data is related to the instance than it can be the right place to put it. Only if you get a lot of these you might want to wrap them in a different class for your own readability (i.e. knowing what is internal and what is external from the instance perspective). The way I generally do it: Manager: anything pertaining a group of Model instances Model: anything pertaining a single Model Instance

Categories : Django

EmberJS: initialize nested model with parent model loaded by ajax
When your App.TourdatesRoute is loaded, all data from the json, will be rendered. And when you click to edit one of these loaded objects, using a link-to for example, ember is smart enough to get the already referenced object, instead of send a new request. So your url will change to: yourhost.com/tourdate/id. When you direct call this url, it will call the App.TourdateRoute model method. Because doesn't have any pre loaded data. But in your case you have a: tourdates.findBy('id', params.tourdate_id); And I can't see in any place the declaration of tourdates. I recommed you to change your TourdateRoute to TourdateIndexRoute so when transitioning to tourdates the ajax call is performed once: App.TourdatesIndexRoute = Ember.Route.extend({ model: function() { return $.getJ

Categories : Javascript

Cannot pass view model back to controller using jquery dialog and model binding with Razor MVC 4
I have had issues with MVC accepting collections as parameters similar to this before. I ended up switching my javascript call to doing an $.ajax post ($.post also has some issues sometimes) speficically including a content and data type $.ajax({ type: 'Post', dataType: 'json', url: 'url-goes-here', data: JSON.stringify({ data: data}), contentType: 'application/json; charset=utf-8' }); Not quite as nice as the auto-binding, but it does post the data back even as a collection.

Categories : Jquery

Calling model.get() on a related model returning null values for attributes with backbone-relational
In your code, related section, correct includeInJson to includeInJSON Backbone-Relational docs about includeInJSON Use dfds.push instead of dfds = dfds.concat, its faster and better to use Comparision Tests - Array concat vs push

Categories : Jquery

How to preserve the Model.Context.cs file header content after updating model from db with Entity Framework?
For the added members, you can create another file that contains another partial of the class. This new file won't be overwritten so anything you've added there should persist between updates. For the changes that aren't new members (like the added line in the constructor), you can edit the Model.Context.tt file directly. This is a simple T4 Text Template used to re-generate the code when the model is updated. It is similar to an ASP.NET page; however, instead of using C# to generate HTML, it uses C# to generate more C#.

Categories : C#

Backbone model change event not firing after setting model
You are missing var before the that variables and other variables... having these variable global is a menace, they can be changed/overwritten outside of this scope before the success callback is called. that = this; //should be - 'var that = this;'

Categories : Jquery

WPF MVVM: INPC and mediating communication between view model & model
For the purpose of this answer, I will call the business object classes 'data types'. In my personal experience, view models are always tied to the data types. You have to have properties of the types that you want to display, so there will always be a reference from the view models namespace to the data types namespace. What you call a model (from your description in your comment) sounds like my view models. My view models have properties, mostly of the type of the various data type classes, and methods, whereas my data type classes just hold properties for the most part... they're just holders of data and reporters of changes really. You seem to be under the impression that the INotifyPropertyChanged interface performs some duties between the 'model' as you call it and the view m

Categories : C#

Saving data to User model from Profile model Cakephp
You can't change values in $this->request->data You're also creating $data and not using it anywhere Try something like this (not tested of course) if ($this->request->is('post')) { $this->Profile->create(); $data = $this->request->data; $data['Profile']['user_id'] = $this->Auth->user('id'); // code implemented below $this->loadModel('User'); if ($this->Profile->save($data)) { //Update user here if Profile saved successfully $this->Profile->User->id = $this->Auth->user('id'); if($this->Profile->User->saveField('profile_created', '1')){ $this->Session->setFlash(__('Your account profile has been created'));

Categories : Cakephp

extjs 4.2 - add() method in Store adding new model as RAW and NOT as a MODEL - error or bug?
You can use store.loadRawData(). This will use your configured Proxy, the mapping settings, etc in the Model / Store. Extracted from documentation: loadRawData( data, [append] ) : Boolean Loads data via the bound Proxy's reader Use this method if you are attempting to load data and want to utilize the configured data reader.

Categories : Extjs

how to add a condition of comparing two fields of the model itself in Django model query
Sure, that's what the "F" object is for! from django.db.models import F # snip return self.exclude(full_score = F('actual_score')) Use QuerySet.exclude here, as you want to not get the results that match. If you really want to use QuerySet.filter, you can use a negated "Q" object: self.filter(~Q(full_score = F('actual_score'))).

Categories : Python

Using pivot model data as a relationship to another model in Laravel 4's Eloquent
There is a way to do this by creating a class that extends IlluminateDatabaseEloquentRelationsPivot. Though this approach also requires adding some code to the two models that own this pivot so that they use the new Pivot when needed. This link discusses the implementation of the Custom Pivot Model: https://github.com/laravel/framework/issues/2093#issuecomment-39154456 use IlluminateDatabaseEloquentRelationsPivot; class SubjectUser extends Pivot { // add your relationships back to User and Subject public function session() { // your relation to session here } } class Subject extends Eloquent { ... public function newPivot(Eloquent $parent, array $attributes, $table, $exists) { if ($parent instanceof User) { return new SubjectUser($parent,

Categories : PHP

Backbone Model Save: sending fields as "model" subobject
If you want to modify the structure of the data you send to the server, then override the toJSON method for your model: toJSON: function () { return { // structure the model as you wish here }; }

Categories : Javascript

What is the right association for a child model that can be attached to different types of parent model?
You can just use an intersection table for this: +---------------------+ | Comments | +---------------------+ | commentID | comment | +---------------------+     +---------------+     | Notes |     +---------------+     | noteID | note |     +---------------+     +-------------------------+     | LearningObjective |     +-------------------------+     | objectiveID | objective |     +-------------------------+ Now for your intersections:     +------------------------------------+     | NoteComment |     +------------------------------------+     | noteCommentID | commentID | noteID |     +------------------------------------+     +----------------------------------------------------

Categories : SQL

Core Data Migration: Do I Need a new Mapping Model for each new Model Version I Add?
Depending on your model changes, you may use "The Default Migration Process". When calling addPersistentStoreWithType:configuration:URL:options:error:, use the flag NSMigratePersistentStoresAutomaticallyOption. Also, I'm sure that unfortunately you need one mapping model for each possible migration. If you have 3 models, you'll have to implement: 1 to 3 and 2 to 3. Core Data is not smart enough to do the intermediate steps automatically :(

Categories : Iphone

Backbone JS add extended model to a collection of its inherited model type
The problem lies in appendItem method. You are calling it in this way: this.appendItem(new input.view({model: title}).el); But in this way you are passing as argument the view el, not the view itself, and so the view.model is undefined! You should refactor appendItem in this way: appendItem: function(view) { this.collection.add(view.model); $(this.container).append(view.el); }, And call it: this.appendItem(new editor.view({model: new editor.model()}));

Categories : Javascript



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.