我想要克隆当前正在编辑的模型.
我找到了几种几乎可以工作的方法.但两者都不完美.
1)model.get('data.attributes')获取除camelCase形式的关系之外的所有属性,生成新的记录,但当然缺少关系.
2)model.serialize()生成一个JSON对象,其中包含所有属性,包括关系.但createRecord由于对象不是camelCased(具有下划线的属性first_name不会被处理),因此无法很好地处理它
创建克隆后,我想transaction.createRecord(App.Document, myNewModelObject)更改/设置几个属性,最后commit().任何人都有一些如何做到这一点的见解?
我正在使用Redactor WYSIWYG编辑器,它允许您在初始化代码之前使用最小标记,如下所示:
<textarea id="redactor" name="content">
…
</textarea>
Run Code Online (Sandbox Code Playgroud)
但是在初始化期间,Redactor将textarea使用以下内容包装它:
<div class="redactor_box">
<div class="redactor_ redactor_editor" contenteditable="true" dir="ltr">
…
</div>
<textarea id="redactor" name="content" style="display: none;">
…
</textarea>
</div>
Run Code Online (Sandbox Code Playgroud)
我目前在Ember做过这个
模板:
{{ view App.RedactorView valueBinding='contentAttributes.headerContent' class='header-redactor' name='headerContent' }}
Run Code Online (Sandbox Code Playgroud)
查看扩展Ember.TextArea:
App.RedactorView = Ember.TextArea.extend({
didInsertElement: function() {
$("#"+this.elementId).redactor();
}
});
Run Code Online (Sandbox Code Playgroud)
这仍然保持绑定textarea(现在隐藏),但我现在需要绑定redactor_editor类.我怎样才能做到这一点?
我正在尝试将NSDictionary发送到TableViewController,数据最初来自.plist文件.我只想将层次结构中存在的对象发送到新的TableViewController.但是当我尝试计算numberOfSectionsInTableView中的项目数时会出现问题.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Gets the dictionary for the currently selected row
NSDictionary *dict = [[data objectForKey:[[data allKeys] objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row];
// Checks if the key "Room" exists
if([dict objectForKey:@"Room"]) {
SalesFairSessionTableViewController *sessionViewController = [[SalesFairSessionTableViewController alloc] init];
// Sets the data in the subview Controller
[sessionViewController setData:[dict objectForKey:@"Room"]];
// And the title
[sessionViewController setTitle:[dict objectForKey:@"Title"]];
// Problem is here... returns EXC_BAD_ACCESS
NSLog(@"%@", [[[dict objectForKey:@"Room"] allKeys] count]);
[self.navigationController pushViewController:sessionViewController animated:YES];
[sessionViewController release];
}
}
Run Code Online (Sandbox Code Playgroud)
如果我只是使用allKeys:
NSLog([[dict objectForKey:@"Room"] allKeys]); …Run Code Online (Sandbox Code Playgroud)