emacs和python更新模块(emacs and python updating modules)
atm我正在使用emacs编写一些python代码,到目前为止它工作得很好,除了一个真的有点烦人的问题。
总是当我在自编写模块中更新内容时,我重新评估缓冲区并且emacs内部的python shell中的模块不会更新。 我总是必须结束python进程并再次启动它以获得更改。 我发现emacs将一些东西复制到tmp目录来执行它们,所以我猜它与此有关。
也许有人在那里有同样的问题,并已解决它,所以帮助将不胜感激
atm i'm using emacs to write some python code, so far it works quite fine except one problem that is really a bit annoying.
Always when I update something inside a self written module i reevaluate the buffer and the module in the python shell inside emacs doesn't get updated. i always have to end the python process and start it again to get the change. I figured out that emacs copies some things to a tmp dir to execute them, so i guess it has something to do with this.
Maybe someone out there had the same problem and solved it already so help would be appreciated
原文:https://stackoverflow.com/questions/6942627
满意答案
这是一个完整的例子。
模型:
public class MyViewModel { public int Year { get; set; } public IEnumerable<SelectListItem> Years { get { return Enumerable.Range(1980, 40).Select(x => new SelectListItem { Value = x.ToString(), Text = x.ToString() }); } } public IList<TheData> Data { get; set; } } public class TheData { public int Year { get; set; } public string Foo { get; set; } public string Bar { get; set; } }
控制器:
public class HomeController : Controller { public ActionResult Index() { var model = new MyViewModel(); return View(model); } [HttpPost] public ActionResult Index(int year) { var model = new[] { new TheData { Year = year, Foo = "foo 1", Bar = "bar 1" }, new TheData { Year = year, Foo = "foo 2", Bar = "bar 2" }, new TheData { Year = year, Foo = "foo 3", Bar = "bar 3" }, }; return PartialView("_data", model); } }
Index.cshtml
查看:@model MyViewModel <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script> <script type="text/javascript"> $(function () { $('#yearsddl').change(function () { $(this).closest('form').trigger('submit'); }); }); </script> @using (Ajax.BeginForm(new AjaxOptions { UpdateTargetId = "data" })) { @Html.DropDownListFor(x => x.Year, Model.Years, new { id = "yearsddl" }) } <table> <thead> <tr> <th>Year</th> <th>Foo</th> <th>Bar</th> </tr> </thead> <tbody id="data"> @Html.Partial("_data", Model.Data ?? Enumerable.Empty<TheData>()) </tbody> </table>
例如,
jquery.unobtrusive-ajax.js
脚本包含移出布局中的索引视图,并且订阅下拉列表更改事件的自定义js应移至单独的js文件中,并从布局中包含。 我只是把它们放在这里来说明视图工作所需的完整示例。
_Data.cshtml
部分:@model IList<TheData> @for (int i = 0; i < Model.Count; i++) { <tr> <td>@Html.DisplayFor(x => x[i].Year)</td> <td>@Html.DisplayFor(x => x[i].Foo)</td> <td>@Html.DisplayFor(x => x[i].Bar)</td> </tr> }
Here's a full example.
Model:
public class MyViewModel { public int Year { get; set; } public IEnumerable<SelectListItem> Years { get { return Enumerable.Range(1980, 40).Select(x => new SelectListItem { Value = x.ToString(), Text = x.ToString() }); } } public IList<TheData> Data { get; set; } } public class TheData { public int Year { get; set; } public string Foo { get; set; } public string Bar { get; set; } }
Controller:
public class HomeController : Controller { public ActionResult Index() { var model = new MyViewModel(); return View(model); } [HttpPost] public ActionResult Index(int year) { var model = new[] { new TheData { Year = year, Foo = "foo 1", Bar = "bar 1" }, new TheData { Year = year, Foo = "foo 2", Bar = "bar 2" }, new TheData { Year = year, Foo = "foo 3", Bar = "bar 3" }, }; return PartialView("_data", model); } }
Index.cshtml
view:@model MyViewModel <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script> <script type="text/javascript"> $(function () { $('#yearsddl').change(function () { $(this).closest('form').trigger('submit'); }); }); </script> @using (Ajax.BeginForm(new AjaxOptions { UpdateTargetId = "data" })) { @Html.DropDownListFor(x => x.Year, Model.Years, new { id = "yearsddl" }) } <table> <thead> <tr> <th>Year</th> <th>Foo</th> <th>Bar</th> </tr> </thead> <tbody id="data"> @Html.Partial("_data", Model.Data ?? Enumerable.Empty<TheData>()) </tbody> </table>
The
jquery.unobtrusive-ajax.js
script inclusion should be moved out of the index view inside the layout for example and the custom js that subscribes for the change event of the dropdownlist should be moved into a separate js file and included from the Layout. I just put them here to illustrate a full example of what's required for the view to work.
_Data.cshtml
partial:@model IList<TheData> @for (int i = 0; i < Model.Count; i++) { <tr> <td>@Html.DisplayFor(x => x[i].Year)</td> <td>@Html.DisplayFor(x => x[i].Foo)</td> <td>@Html.DisplayFor(x => x[i].Bar)</td> </tr> }
相关问答
更多ASP.NET AJAX与ASP.NET MVC中的jQuery(ASP.NET AJAX vs jQuery in ASP.NET MVC)
在ASP.Net MVC中,ModelState可以与ajax更新一起使用吗?(In ASP.Net MVC, can ModelState be used with an ajax update?)
如何在ASP.NET MVC中制作更新面板(How to make update panel in ASP.NET MVC)
如何在Asp.net MVC 4中使用简单的Ajax Beginform?(How to use Simple Ajax Beginform in Asp.net MVC 4? [closed])
ASP.NET MVC AJAX操作模型(ASP.NET MVC AJAX manipulating model)
在asp.net MVC 3中简单的Ajax,更新模型并重新渲染部分(Simple Ajax in asp.net MVC 3, update the model and rerender part)
在asp.net mvc中使用ajax进行更新(Update using ajax in asp.net mvc)
使用Ajax的ASP.net MVC(ASP.net MVC with Ajax)
如何在asp.net mvc中使用Ajax更新View?(How to update View using Ajax in asp.net mvc?)
模型没有用asp.net mvc中的ajax帖子更新?(Model is not updated with ajax post in asp.net mvc?)
相关文章
更多顶 Hadoop、Pig、Hive、Storm、NOSQL 学习资源收集【Updating】
fw:Hadoop、Pig、Hive、Storm、NOSQL 学习资源收集【Updating】
探索 Python,第 1 部分: Python 的内置数值类型
Python资源索引 【转载】
python下载pps视频
python字典操作
python top project of 2013
Mod_python: The Long Story
【转帖】Python 资源索引
(转)Python WEB应用框架纵览
最新问答
更多python的访问器方法有哪些
使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
透明度错误IE11(Transparency bug IE11)
linux的基本操作命令。。。
响应navi重叠h1和nav上的h1链接不起作用(Responsive navi overlaps h1 and navi links on h1 isn't working)
在C中读取文件:“r”和“a +”标志的不同行为(Reading a File in C: different behavior for “r” and “a+” flags)
NFC提供什么样的带宽?(What Kind of Bandwidth does NFC Provide?)
元素上的盒子阴影行为(box-shadow behaviour on elements)
它看起来像只在Windows上的Chrome的错误。 我在Google Canary (Chrome 63)中也进行了测试,问题依然存在,所以有可能它不会很快修复。 这个问题是由overflow: auto引起的overflow: auto ,在你的情况下,它可以很容易地通过删除或设置为可见(默认)来解决。 但是 ,将鼠标悬停在右侧(顶部和底部)时,会出现滚动条。 一个解决方案可以设置overflow: hidden的身体,所以预期的结果是所需的。 我想指出,这不是一个很好的解决方案,但我建议暂
Laravel检查是否存在记录(Laravel Checking If a Record Exists)
这取决于您是否要以后与用户合作,或仅检查是否存在。 如果要使用用户对象(如果存在): $user = User::where('email', '=', Input::get('email'))->first(); if ($user === null) { // user doesn't exist } 如果你只想检查 if (User::where('email', '=', Input::get('email'))->count() > 0) { // user found
设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)
$scope.getData= function () { var reader = new FileReader(); reader.onload = $('input[type=file]')[0].files; var img = new Image(); img.src =(reader.onload[0].result); img.onload = function() { if(this.width > 640
Copyright ©2023
peixunduo.com All
Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!
Laravel检查是否存在记录(Laravel Checking If a Record Exists)
设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!