我有一系列按钮,点击时会在按钮下方显示一个弹出菜单.我想将按钮的位置传递给视图.我怎样才能做到这一点?
ItemView = Backbone.View.extend({
tagName: 'li',
events: {
'click': 'showMenu'
},
initialize: function() {
_.bindAll(this, 'render');
},
render: function() {
return $(this.el).html(this.model.get('name'));
},
showMenu: function() {
var itemColl = new ItemColl();
new MenuView({collection: itemColl}); // how to pass the position of menu here?
}
});
Run Code Online (Sandbox Code Playgroud) 我试图动态创建一个常量名称,然后获取该值.
define( CONSTANT_1 , "Some value" ) ;
// try to use it dynamically ...
$constant_number = 1 ;
$constant_name = ("CONSTANT_" . $constant_number) ;
// try to assign the constant value to a variable...
$constant_value = $constant_name;
Run Code Online (Sandbox Code Playgroud)
但是我发现$ constant值仍然包含常量的NAME,而不是VALUE.
我也尝试了第二级间接$$constant_name
但是这会使它变量而不是常量.
有人可以对此有所了解吗?
我在Subversion中遇到版本控制问题.我从存储库检查了一个工作副本,并锁定了它的所有文件.然后,在没有释放锁的情况下,我从磁盘中删除了该文件夹.
如何打破驻留在存储库中的锁?我在Windows上使用TortoiseSVN.是否有一个命令来递归锁定文件夹的锁?
通常在html中编写视图模板时,我习惯添加一些有用的注释会导致测试时花费大量时间.
考虑这段代码......
<!-- Here starts the sidebar -->
<div id="sidebar">
....
</div>
<!-- Here starts the main contents pane -->
<div id="main-contents">
...
</div>
<!-- Here starts the footer -->
<div id="footer">
...
</div>
Run Code Online (Sandbox Code Playgroud)
现在,如果我必须隐藏视图模板的某些部分,在php的情况下,我只需选择所需的代码并放置单行注释(大多数时候使用快捷键).
但是,在html代码中,只有块注释有效,我最终删除所有结束注释标记( - >),直到我希望注释发生的位置 - 这样的事情......
<!-- Here starts the sidebar
<div id="sidebar">
....
</div>
<!-- Here starts the main contents pane
<div id="main-contents">
...
</div>
<!-- Here starts the footer
<div id="footer">
...
</div>-->
Run Code Online (Sandbox Code Playgroud)
然后,当我完成测试时,我必须经历将那些结束标签放回去的痛苦.
在HTML中是否有更好的和省时的块注释方式?
我用javascript在javascript中定义了一个类...
// file_a.js
function class_a() {
this.prop1 = null;
this.prop2 = null;
}
// file_b.js
var obj = new class_a;
// I need to check here if class_a exists
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
问候
在PHP中有一个函数,它接受一个字符串,一个数字(i
)和一个字符(x
),然后用()替换position(i
)处的字符x
?
如果没有,有人可以帮助我实施吗?
我想使用codeigniter活动记录实现SQL语句.
UPDATE tags SET usage = usage+1 WHERE tag="java";
Run Code Online (Sandbox Code Playgroud)
如何使用Codeigniter活动记录实现此目的?
问候
我在这里关注演示
http://jquery.bassistance.de/validate/demo/marketo/
在提交表单时,如果字段为空,输入框和其他字段如何在它们周围形成红色边框?为了得到这个,我必须在插件中添加什么?
更新
$("#profile_form").validate({
rules: {
nickname: "required",
address: "required"
},
messages: {
nickname: "(required)",
address: " (required)"
}
});
Run Code Online (Sandbox Code Playgroud)
我知道如何通过css获取边框,我需要知道validate插件如何更改css.
问候
我刚开始使用iPhone开发.在我必须在tabbar控制器的表视图中显示存储在sqlite db中的一些数据的示例之一中,我不得不将sqlite文件从应用程序包移动到documents文件夹.
我使用了应用程序模板 - 用于iPhone的iOS>应用程序>基于窗口的应用程序(用于存储的已用核心数据)
在由XCode生成的模板中(基本sdk设置为最新iOS = 4.2),以下代码在那里......
- (NSURL *)applicationDocumentsDirectory {
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}
Run Code Online (Sandbox Code Playgroud)
在尝试获取文档文件夹的路径时,我使用上面给出的方法,就像这样......
NSString *documentDirectory = [self applicationDocumentsDirectory];
Run Code Online (Sandbox Code Playgroud)
这给了一个警告 - warning: incompatible Objective-C types initializing 'struct NSURL *', expected 'struct NSString *'
所以我把代码更改为以下...
// Added the message absoluteString over here
NSString *documentDirectory = [[self applicationDocumentsDirectory] absoluteString];
NSString *writableDBPath = [documentDirectory stringByAppendingPathComponent:@"mydb.sqlite"];
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"mydb.sqlite"];
BOOL success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error];
if (!success) {
NSLog(@"Failed to create writable database …
Run Code Online (Sandbox Code Playgroud) javascript ×2
php ×2
activerecord ×1
backbone.js ×1
bing ×1
codeigniter ×1
coding-style ×1
comments ×1
constants ×1
css ×1
database ×1
html ×1
indirection ×1
iphone ×1
jquery ×1
locking ×1
replace ×1
search-box ×1
string ×1
svn ×1
validation ×1