我有这个淘汰代码:
function Task(data) {
this.title = ko.observable(data.title);
this.isDone = ko.observable(data.isDone);
}
function TaskListViewModel() {
// Data
var self = this;
self.tasks = ko.observableArray([]);
self.newTaskText = ko.observable();
self.incompleteTasks = ko.computed(function() {
return ko.utils.arrayFilter(self.tasks(), function(task) { return !task.isDone() });
});
// Operations
self.addTask = function() {
self.tasks.push(new Task({ title: this.newTaskText() }));
self.newTaskText("");
};
self.removeTask = function(task) { self.tasks.remove(task) };
}
ko.applyBindings(new TaskListViewModel());
Run Code Online (Sandbox Code Playgroud)
这个html:
<head>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="knockout-2.0.0.js"></script>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<h3>Tasks</h3>
<form data-bind="submit: addTask">
Add task: <input …Run Code Online (Sandbox Code Playgroud) 我试图before_save在rails模型中的方法中添加异常,但在视图中,不存在任何错误消息.
模型:
before_save do
doing_some_stuff
begin
File.open('some_file', 'w+') do |file|
if file.write(file_content)
return true
else
return false
end
end
rescue => e
self.errors.add(:base, e.message)
return false
end
Run Code Online (Sandbox Code Playgroud)
视图:
<%= @model.errors.any? %>
Run Code Online (Sandbox Code Playgroud)
这总是错误的.
如何向模型添加错误消息?
编辑:
问题是,我在update_attribute函数之后进行了重定向,而不是再次呈现操作.谢谢你的帮助.
我有两种元素
<i rel="tooltip" class='icon-ok'>
<i title="Teste" class='icon-info'>
Run Code Online (Sandbox Code Playgroud)
第一个是工具提示效果,第二个是弹出窗口
我正在尝试做的是避免返工,所以我不需要在每个html上创建一个基于类的脚本.
我在我的基础html上做了这个:
$('body').find('i').tooltip();
Run Code Online (Sandbox Code Playgroud)
问题是它在<i>没有rel属性的情况下在其他元素上添加工具提示效果.
我需要使用rel属性搜索元素并在其上设置工具提示效果.
谢谢
编辑
如果我尝试与正确答案所说的相反,请获取<i>不带rel属性的元素.在这里找到解决方案:jQuery选择器 - 查找没有指定属性的对象
vrutberg -jQuery("li:not([style])").hide();
我需要像创建布局这个,但所有的分隔的文件,如容器:
top.xhtml
<p:layout fullPage="true">
<p:layoutUnit position="north" header="#{support.applicationTitle}">
<h:form>
<p:menubar>
<p:menuitem value="Quit" icon="ui-icon-close" action="#{userController.logOut()}" />
</p:menubar>
</h:form>
</p:layoutUnit>
Run Code Online (Sandbox Code Playgroud)
没有</p:layout>因为它将在我的footer.xhtml上关闭像:
<p:layoutUnit position="south" header="© 2012 - 2012 PORTAL DE IDEIAS">
</p:layoutUnit></p:layout>
Run Code Online (Sandbox Code Playgroud)
我试过这两个文件,但是我收到一个错误,告诉我需要关闭布局标签,这是正确的,但我怎样才能解决我的问题?这是模板的最佳方法吗?另一个问题是布局标签需要一个中心layoutUnit
我正在尝试MongoDB,但我不理解它创建的文件.
如果我在我的db collection上创建一个文件让我们说用户,它会在我的/ data/db /上创建这些文件
_tmp (folder)
mongod.lock
users.0 - 16.8MB
users.1 - 33.6MB
users.ns - 16.8MB
Run Code Online (Sandbox Code Playgroud)
我添加了一些文件,文件大小没有改变.我在这里有点丢失......有谁知道这些文件是如何工作的?我试过用gedit/vim打开它们什么都没有.
在此先感谢您的帮助.
是否可以像这样定义返回类型?
public static function bool Test($value)
{
return $value; //this value will be bool
}
Run Code Online (Sandbox Code Playgroud) 你好我得到JS错误:
Uncaught SyntaxError: Unexpected identifier
Run Code Online (Sandbox Code Playgroud)
这里
<script type="text/javascript">
var cur_level = 1;
var ids_arr = new Array(<?php echo $max_level?>);
var im_here = new Array(<?php echo $max_level?>);
ids_arr[0] = 1;
im_here[0] = "|";
function displayData(id, level, used, title)
{
if(used){
choice = document.getElementById('divv'+id).innerHTML;
document.getElementById('test_div').innerHTML = choice;
} else {
document.getElementById('test_div').innerHTML = ' No lerning paths to show.';
updateLinksDiv(id, level, title);
}
}
function updateLinksDiv(id, level, title)
{
var links_div_info = document.getElementById('links_parent_'+id);
var tmpHTML = '';
var here = '';
for(i=0;i<level;i++){
here+= …Run Code Online (Sandbox Code Playgroud) 我想懒惰加载类但没有成功
<?php
class Employee{
function __autoload($class){
require_once($class);
}
function display(){
$obj = new employeeModel();
$obj->printSomthing();
}
}
Run Code Online (Sandbox Code Playgroud)
现在当我做这个
function display(){
require_once('emplpyeeModel.php');
$obj = new employeeModel();
$obj->printSomthing();
}
Run Code Online (Sandbox Code Playgroud)
它的工作原理,但我想懒得加载这个类.
我有一个登录按钮的视图.单击该按钮时,我添加了一个包含用于登录的字段的视图.发生这种情况时,我需要调暗父视图.我怎么做的?
我正在使用Twitter Bootstrap.
警报HTML代码是:
<div class="alert alert-block">
<a class="close" data-dismiss="alert" href="#">×</a>
<h4 class="alert-heading">Warning!</h4>
Best check yo self, you're not...
</div>
Run Code Online (Sandbox Code Playgroud)
我<h:messages />用来显示我的表单错误,信息和警告消息,如下所示:
<h:messages errorClass="alert alert-error" infoClass="alert alert-info" warnClass="alert alert-warning"/>
Run Code Online (Sandbox Code Playgroud)
颜色和圆角是可以的,但我需要添加关闭链接:
<a class="close" data-dismiss="alert" href="#">×</a>
Run Code Online (Sandbox Code Playgroud)
我该怎么做<h:messages/>?
编辑
如果需要更好的理解,这里是警报样式的twitter bootstrap链接:http: //twitter.github.com/bootstrap/components.html#alerts
html ×2
javascript ×2
jsf ×2
php ×2
cocoa-touch ×1
facelets ×1
file ×1
function ×1
ios ×1
jquery ×1
knockout.js ×1
layout ×1
mongodb ×1
objective-c ×1
primefaces ×1
return ×1
return-type ×1
swift ×1
templates ×1