调试中的局部视图坐在一个脚本 [英] Debug a script that sits in a partial view

查看:137
本文介绍了调试中的局部视图坐在一个脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我无法调试驻留在局部视图脚本,即获取运行时创建?
看到剧本的脚本列表(在Chrome为例)并调试它,我必须把它移动到正规军的观点在上层或我必须将它移动到一个单独的.js文件。
但是,如果脚本非常小,我不希望任何地方移动它,并仍然希望能够调试呢?

Why I can't debug scripts that reside in a partial view, that gets created in runtime? To see the script in the list of scripts (in Chrome for example) and debug it, I have to move it to the "regular" view on the upper level or I have to move it to a separate .js file. But what, if the script so small that I don't want to move it anywhere, and still want to be able to debug it?

推荐答案

如果你不加载通过AJAX的局部视图(视图是发生在初始页面渲染),你可以使用调试。如果你想运行code被添加到IE浏览器的DOM会不知道实际的code被定位在要调试。所以:

If you do not load the partial view via ajax (the view is in place at the initial page rendering) you can use 'debugger'. If the code you want to run is added to the dom IE will not know where the actual code is located that you want to debug. So:

// javascript
var foo = 2;
debugger;
// more javascript

这篇关于调试中的局部视图坐在一个脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆