knockoutjs映射嵌套元素不绑定(knockoutjs mapping nested elements is not binding)

基本上看从ajax调用映射json。 我的js

var mapping = {
    create: function(options) {
    return new Person(options.data.id,options.data.name,options.data.surname,options.data.address,options.data.amounts);
    },
    'address': {
        create: function(options) {
            return new Address(options.data.id,options.data.street,options.data.number);
        }
    },
    'Amounts': {
        create: function(options) {
            return new Amount(options.data.id,options.data.price,options.data.iva);
        }
    }    
};

我收到一个错误:ReferenceError:fullAddress没有定义我的小提琴: http//jsfiddle.net/2coj72yn/1/谢谢你的希望。


basically looking mapping a json from ajax call. my js

var mapping = {
    create: function(options) {
    return new Person(options.data.id,options.data.name,options.data.surname,options.data.address,options.data.amounts);
    },
    'address': {
        create: function(options) {
            return new Address(options.data.id,options.data.street,options.data.number);
        }
    },
    'Amounts': {
        create: function(options) {
            return new Amount(options.data.id,options.data.price,options.data.iva);
        }
    }    
};

I get an error : ReferenceError : fullAddress is not defined my fiddle: http://jsfiddle.net/2coj72yn/1/ Thanks for hope.


原文:https://stackoverflow.com/questions/27851817
2022-09-15 12:09

满意答案

试试这个,但在实现之前请阅读向后兼容性

public boolean dispatchKeyEvent(KeyEvent event) {
final int keycode = event.getKeyCode();
final int action = event.getAction();
if (keycode == KeyEvent.KEYCODE_MENU && action == KeyEvent.ACTION_UP) {
    return true; // consume the key press
}
return super.dispatchKeyEvent(event);
}

Try this, but before implement this please read Backwards Compatibility

public boolean dispatchKeyEvent(KeyEvent event) {
final int keycode = event.getKeyCode();
final int action = event.getAction();
if (keycode == KeyEvent.KEYCODE_MENU && action == KeyEvent.ACTION_UP) {
    return true; // consume the key press
}
return super.dispatchKeyEvent(event);
}

相关问答

更多

如何在我的Android应用程序中关闭物理按钮的声音点击(声音效果)?(How to turn off physical button's sound click (sound effects) in my Android app?)

您可以在应用程序启动时将声音静音,并在完成时取消静音 @override public void onResume(){ super.onResume(); AudioManager mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE); mgr.setStreamMute(AudioManager.STREAM_SYSTEM, true); } @override public void onPause...

使用PhoneGap在Android中禁用菜单按钮(Disabling menu button in Android using PhoneGap)

我有同样的问题。 似乎是PhoneGap 2.0中的新默认值。 在src文件夹下的.java文件中(MainActivity.java似乎是默认文件名),注释掉onCreateOptionsMenu函数。 I had the same problem. Seems to be a new default in PhoneGap 2.0. In the .java file under the src folder (MainActivity.java appears to be the defau...

android如何在物理按钮上执行反馈触觉?(How does android perform a feedback haptic on physical button?)

相关的代码行可以在PhoneWindowManager.java中找到 - > public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn) 。(在其他uplever应用程序可以处理之前调用它); 在判断KeyEvent代码后,它将调用mVibrator.vibrate(pattern[0]); 通过调用mVibrator = (Vibrator)context.getSyste...

在android中禁用物理菜单按钮(软/硬)(Disable physical menu button(Soft/Hard) in android)

试试这个,但在实现之前请阅读向后兼容性 public boolean dispatchKeyEvent(KeyEvent event) { final int keycode = event.getKeyCode(); final int action = event.getAction(); if (keycode == KeyEvent.KEYCODE_MENU && action == KeyEvent.ACTION_UP) { return true; // consume the...

在物理菜单按钮上显示导航抽屉(show navigation drawer on physical menu button)

DrawerLayout.openDrawer(Gravity.LEFT)是你正在寻找的。 顺便说一句,我认为这不是一个糟糕的想法,因为很多人还不熟悉抽屉。 DrawerLayout.openDrawer(Gravity.LEFT) is what you are looking for. Btw I don't think that it is a bad think to do, since a lot of people is not familiar with the drawer yet...

更新的Android设备上的菜单按钮(Menu button on newer android devices)

我已经实现了一个遗留菜单按钮 做什么的? 如果您的应用程序是遗留应用程序,Android会自行处理这个问题,它会在Honeycomb上添加屏幕菜单按钮,因此您不需要打扰。 看到这篇文章: 告别菜单按钮 如果您的应用程序在没有专用菜单按钮的设备上运行,系统将根据您在清单元素中声明支持的API级别决定是否将操作溢出添加到导航栏。 逻辑归结为: 如果将minSdkVersion或targetSdkVersion设置为11或更高,系统将不会添加旧版溢出按钮。 否则,系统将在Android 3.0或更高版本...

如何在Android设备上检测硬/软后退按钮?(How to detect Hard/Soft back button on Android device?)

我认为这应该有效 查询框架,了解连接到设备的任何键盘上是否存在任何能够生成给定密钥代码的物理密钥。 boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); Android开发者文档 I think this should work Queries the framework about whether any physical keys exist on the any keyboard attached...

如何禁用Android 4.0以上的主页/菜单按钮?(How to disable Home/Menu button in Android above 4.0?)

一种方法是显示一个对话框,其中LayoutParams类型设置为TYPE_SYSTEM_ERROR ,并将此对话框的所有者设置为“锁屏”活动以阻止主页按钮。 下面是一个如何做到这一点的示例: 更新:看起来这只适用于Android 4之前的版本。+ https://github.com/Joisar/LockScreenApp/blob/master/LockScreenApp/src/com/mehuljoisar/lockscreen/ utils的/ LockscreenUtils.java ...

如何以编程方式按下android的物理按钮(How to press physical buttons of android programatically)

我建议你以编程方式增加/减少音量,这会有点容易,但是如果你想将它用于其他一些过程那么你可以检查下面的代码 - 编辑 - 我之前给出的片段不起作用,但是这个确实如此。 它使用runnable,因此try catch块是必需的。 new Thread(new Runnable() { @Override public void run() { try { Inst...

软菜单按钮有什么用处?(What's the deal with the soft menu button?)

除了它消失了,我无法弄清楚为什么 你摆脱了行动吧。 溢出功能显示在操作栏中,然后仅显示在缺少屏幕外MENU键的设备上。 在这个旧的Android开发者博客文章中可以找到对此的更长解释,以及在系统栏中有...可用性的一些遗留场景。 请问,这些天选项菜单上的派对线是什么? 如果您没有使用操作栏,请滚动自己的“菜单”构造。 except it went away and I can't figure out why You got rid of the action bar. The overflow ...

相关文章

更多

Hibernate Search(基于version3.4)--第四章Mapping entities to the index structure

Mapping entities to the index structure 4.1. 映射一个实 ...

elasticsearch 口水篇(6) Mapping 定义索引

前面我们感觉ES就想是一个nosql数据库,支持Free Schema。 接触过Lucene、solr ...

ElasticSearch入门-Get Mapping

想要在Java API中获得一个mapping 还真困难,以此铭记。 import org.elast ...

ElasticSearch入门-结构定义之Mapping

相当于数据库的表结构的定义,elasticsearch的mapping 也很重要。直接关系到性能及搜索 ...

My W3C Custom Mapping File

[hdhw] HotKey=W Tip=Train Dragonha|cffffcc00w|r ...

spring 嵌套事务 的 加锁 问题

有两个service:ServiceA 和 ServiceB ServiceA { metho ...

微信wap开发,页面显示元素不全-微信开发(asp.net)

最近在开发的微信的微商城,出现这样一种情况: pc上浏览正常,但是一到手机上浏览就会缺少部分元素 解决 ...

用Hibernate映射mysql问题(Timestamp)

我知道这个是个常见问题,我已经看了论坛帖子和查阅相关资料,始终没找到好的解决方法,如果有空的帮解答下吧 ...

hibernate中多对多映射关系

一个用户可以授予多种角色,一种角色可以分配​给多个用户。这就是一种多对多的关系。使用Many2Many ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本