我的Backbone应用程序有一个名为schedule的视图,我对成功和错误调用正确函数的区别有点困惑,我尝试了下面列出的两个可能但我没有什么区别和什么是正确的从外部视图中放置的路由器调用函数的方法:
第一种方式:
require([
'app/collections/schedule',
'app/views/schedule'
], function(ScheduleCollection, ScheduleView) {
var scheduleCollection = new ScheduleCollection(),
scheduleView = new ScheduleView({
model: scheduleCollection
});
scheduleCollection.fetch({
reset: true,
success: function(){
scheduleView.successHandler();
},
error: function(){
scheduleView.errorHandler()
}
});
});
Run Code Online (Sandbox Code Playgroud)
第二种方式
require([
'app/collections/schedule',
'app/views/schedule'
], function(ScheduleCollection, ScheduleView) {
var scheduleCollection = new ScheduleCollection(),
scheduleView = new ScheduleView({
model: scheduleCollection
});
scheduleCollection.fetch({
reset: true,
success: scheduleView.successHandler(),
error: scheduleView.errorHandler()
});
});
Run Code Online (Sandbox Code Playgroud)
在scheduleView中
successHandler: function(){
console.log('success');
}
erroHandler: function(){
console.log('error');
}
Run Code Online (Sandbox Code Playgroud) 我们正在构建需要所有页面的登录信息的系统.该应用程序被设计为使用codeigniter作为Phil Sturgeon库的Restful应用程序.此库仅使用API密钥通过HTTPS连接的每个请求发送api调用来授权api调用.
即使它使用2路认证或仅使用API密钥.我正在寻找一段时间是以下场景:
服务器检查信息是否有效,然后:
API KEY应由服务器提供给客户端,作为此用户名标识的资源(这是问题??? !!!)
如何以安全的方式将API密钥发送到客户端?
如果你能给出一个例子,那将是一个很大的帮助,因为我找到并阅读了很多文章
:)
看看这段代码
<div class="preview">
<img src="link" alt="" class="overlay" />
</div>
Run Code Online (Sandbox Code Playgroud)
我需要做的是将内部div调用"overlay"包装,然后添加另一个名为"overlay2"的div,如下所示
<div class="preview">
<div class="overlay">
<img src="link" alt="" class="overlay" />
<div class="overlay2"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我试图使用.wrap和追加但我不知道如何使用一个命令
我是backbone.js的新用户,并测试我如何使用它,最近几天我测试了如何使用route来通过集合更改视图数据.
在目前的情况下,我遇到了一个问题,当我试图在router.js中创建一个ScheduleView实例时,控制台会记录以下错误消息:
TypeError: ScheduleView is not a constructor
Run Code Online (Sandbox Code Playgroud)
下面是调度模块{view,collection,model} + router.js三页的代码
路由器
// Filename: router.js
define([
'jquery',
'underscore',
'backbone',
'app/views/schedule',
'app/collections/schedule'
], function($, _, Backbone, ScheduleView, ScheduleCollection) {
var AppRouter = Backbone.Router.extend({
routes: {
// Define some URL routes
'schedule': 'scheduleRoute',
// Default
'*actions': 'defaultRoute'
},
scheduleRoute: function() {
// Create a new instance of the collection
// You need to set the url in the collection as well to hit the server
var schedulecollection = new ScheduleCollection();
// Pass …Run Code Online (Sandbox Code Playgroud) 我正在使用codeigniter构建自己的REST Web服务,该应用程序具有名为“ calls ” 的资源,并且可以通过POST方法访问它,
“ 调用 ”函数通过使用以下内容类型的Curl调用通过json对象接收四个参数[id,manager,department,level]作为json对象:application / json
然后我正在使用codeigniter form_validation()库来验证请求,然后在form_validation()上没有错误的情况下返回响应数组
以下是通话功能代码
function calls_post() {
$this->load->model('api/central');
$this->load->library('form_validation');
//validation rules
$this->form_validation->set_error_delimiters('', '');
$this->form_validation->set_rules('id', 'id', 'required|numeric');
$this->form_validation->set_rules('manager', 'manager', 'required|numeric');
$this->form_validation->set_rules('department', 'department', 'required');
$this->form_validation->set_rules('level', 'level', 'required|numeric');
if ($this->form_validation->run() === FALSE) {
$employeeId = $this->form_validation->error('id') ? $this->form_validation->error('id') : $this->post('id');
$manager = $this->form_validation->error('manager') ? $this->form_validation->error('manager') : $this->post('manager');
$department = $this->form_validation->error('department') ? $this->form_validation->error('department') : $this->post('department');
$level = $this->form_validation->error('level') ? $this->form_validation->error('level') : $this->post('level');
$response = …Run Code Online (Sandbox Code Playgroud) 我怎么能建立一个以下字符串数组:
$scope = "calls:full,departments:full,employees:full,companies:full,stages:full,accounts:full,resources:full,products:full,reports:full";
Run Code Online (Sandbox Code Playgroud)
像这样代表它:
$scope = array(
'calls' => full,
'departments' => full,
'employees' => full,
.... and so on >>
);
Run Code Online (Sandbox Code Playgroud)