javascriptmvc

Server-side vs. Client-side (AJAX) Loading

Deadly 提交于 2020-01-05 13:12:40
问题 I was wondering what is considered best practice. Let's say I have a dropdown select widget. Should it be preloaded with content when the page is served up from the server or once it is loaded, should an AJAX request be made to retrieve the contents and then populate it? I kinda like the idea of loading it empty and issuing an AJAX call to retrieve the contents. But is that going to result in slower page loading times. Especially if the page has several widgets that need to be loaded with

Server-side vs. Client-side (AJAX) Loading

为君一笑 提交于 2020-01-05 13:10:54
问题 I was wondering what is considered best practice. Let's say I have a dropdown select widget. Should it be preloaded with content when the page is served up from the server or once it is loaded, should an AJAX request be made to retrieve the contents and then populate it? I kinda like the idea of loading it empty and issuing an AJAX call to retrieve the contents. But is that going to result in slower page loading times. Especially if the page has several widgets that need to be loaded with

call controller in JavascriptMVC

纵饮孤独 提交于 2019-12-25 00:40:52
问题 I have two controllers, init : jQuery.Controller.extend('App.Controllers.Init', { onDocument: true },{ load: function() { //call App.Controllers.Tabs on $('#tabs') //it is not that easy as $('#tabs').tabs() -> Throws: Object doesn't support this property or method } }); And tabs : jQuery.Controller.extend('App.Controllers.Tabs,... How to call tabs in init? 回答1: You need to: $('#tabs').app_tabs() Just cut the "controller" word out. Make all letters lowercase, and change dots "." to "_" One

Rendering ember component outside parent template

匆匆过客 提交于 2019-12-22 13:30:16
问题 Imagine the following situation. I have a sidebar positioned absolutely and then some more stuff positioned absolutely within that sidebar. In that sidebar I have a button, which shows a menu, the template looks like this: <button>Click me</button> {{#if shouldDisplayMenu}} {{view App.MyMenu}} {{/if}} What I like about this solution and want to keep is that the menu in the template is defined right next to the button, making for nice maintainability. The problem is that I want the menu to be

Backbone.js - Binding from one view to another?

懵懂的女人 提交于 2019-12-21 15:40:30
问题 I have a main app view, with a filter menu in the header. When it's clicked, I want to filter content in a seperate news-feed view. But I don't know how to bind events (and pass class data) from clicks in one view to a function in another. How can I accomplish this? 回答1: There are a number of ways to accomplish this, but probably you want to create a model object, which is shared between the two views. Then on 'click' in view one, update the model object, and bind 'on change' in view two to

How to handle a simple click event in Backbone.js?

耗尽温柔 提交于 2019-12-12 01:23:13
问题 I am having difficulty with something very simple in Backbone. I want to wire up the <h1> in my page so that when the user clicks on it, it returns seamlessly to the homepage, without a postback. This is the HTML: <h1><a id="home" href="/">Home</a></h1> (UPDATE: fixed ID as suggested by commenter.) And this is my Backbone view and router: var HomeView = Backbone.View.extend({ initialize: function() { console.log('initializing HomeView'); }, events: { "click a#home": "goHome" }, goHome:

CanJS add custom MODEL method

梦想与她 提交于 2019-12-08 08:32:15
问题 I want to add another function to get result from a CanJs Model i Have something like this: VideomakerModel = can.Model({ id:'ID', findAll: 'GET /videomakers/', findNear: function( params ){ return $.post("/get_near_videomakers/", {address:params.address}, undefined ,"json") } },{}); VideomakerModel.findNear({address : "Milan"}, function(videomakers) { var myList = new VideomakerControl($('#accordionVm'), { videomakers : videomakers, view: 'videomakersList' }); }); If I name the method

AngularJS - open controller in a dialog (template loaded dynamically)

不羁的心 提交于 2019-12-08 03:06:01
问题 I'm playing around with AngularJS. I'm using a controller and a templateUrl to have things done automagically :) Currently the layout has only <div ng-view></div> directive into which all the things are loaded. I'd like to open the modal (Bootstrap or jQuery UI, doesn't matter) and load there ( inside a modal's body ) the controller specified by given link. Just like every link "opens" (loads the template & does all the DOM compilation & linking) inside my main ng-view , I'd like some of the

AngularJS - open controller in a dialog (template loaded dynamically)

不问归期 提交于 2019-12-06 05:52:08
I'm playing around with AngularJS. I'm using a controller and a templateUrl to have things done automagically :) Currently the layout has only <div ng-view></div> directive into which all the things are loaded. I'd like to open the modal (Bootstrap or jQuery UI, doesn't matter) and load there ( inside a modal's body ) the controller specified by given link. Just like every link "opens" (loads the template & does all the DOM compilation & linking) inside my main ng-view , I'd like some of the links to open inside the modal. I've checked out what AngularStrap and Angular-UI Bootstrap has to

Rendering ember component outside parent template

允我心安 提交于 2019-12-06 05:39:35
Imagine the following situation. I have a sidebar positioned absolutely and then some more stuff positioned absolutely within that sidebar. In that sidebar I have a button, which shows a menu, the template looks like this: <button>Click me</button> {{#if shouldDisplayMenu}} {{view App.MyMenu}} {{/if}} What I like about this solution and want to keep is that the menu in the template is defined right next to the button, making for nice maintainability. The problem is that I want the menu to be positioned relative to the viewport, i.e. rendered to document.body and positioned using position