城堡单轨列车中的 Jeditable 问题

发布于 2024-09-26 21:20:41 字数 2422 浏览 5 评论 0原文

我正在尝试在我的第一个城堡单轨 mvc 应用程序中使用 Jeditables (http://www.appelsiini.net/projects/jeditable)

我设法让文本框出现并进行 ajax 调用,我的问题是现在 ajax 之后调用编辑后的文本返回不会更改,调用后我无法得到响应

这是我的页面

<head>
 <link href="../../Styles/Main.css" rel="stylesheet" type="text/css" />
    <script src="../../JavaScript/jQuery1.4.2.js" type="text/javascript"></script>
    <script src="../../JavaScript/EditInLine.js" type="text/javascript"></script>

 <script type="text/javascript">
  $(document).ready(function() {
   $('.editable').editable('/Home/Save', { 
        id        : 'editableId',
           name    : 'editableText',
     type      : 'textarea',
     cancel    : 'Cancel',
     submit    : 'OK',
     indicator : '<img src="img/indicator.gif">',
     tooltip   : 'Click to edit...',
     width     : '200',
     style     : 'display: inline',
     callbac   : function(value, settings) {
        alert(value);  
      return value;
    }

    });
  });
 </script>

</head>
<body>    


<label id='1' class='editable '>Some text</label>


</body>
</html>

,这是我的控制器

using Castle.MonoRail.Framework;
using System;
using EditInLine.Model.Interfaces;
using EditInLine.Model;

namespace EditInLine.Controllers
{
    [Layout("Default"), Rescue("Default")]
    public class HomeController : SmartDispatcherController
    {
        private EditableElement editableElement;
        private EditableElement EditableElement
        {
            get
            {
                if (Session["EditableElement"] == null)
                {
                    Session["EditableElement"] = new EditableElement { Id = 1, Text = "Some text", CssClass = "editable" };
                }
                return (EditableElement)Session["EditableElement"];
            }            
        }


        public void Index()
        {
            PropertyBag["IsAdmin"] = true;
            PropertyBag["element"] = EditableElement;
        }

        public void Save()
        {
            var elementId = Convert.ToInt32(Request.Form["editableId"]);
            var text = Request.Form["editableText"];  

            var element = new EditableElement { Id = elementId, CssClass = "editable", Text = text };

            Session["EditableElement"] = element;            

        }


    }
}

感谢您的帮助

I am trying to use Jeditables (http://www.appelsiini.net/projects/jeditable) in my first castle monorail mvc application

I managed to have the textbox appearing and to the the ajax call, my problem is now that after the ajax call the edited text returs is not changes and i can t get the response after the call

this is my page

<head>
 <link href="../../Styles/Main.css" rel="stylesheet" type="text/css" />
    <script src="../../JavaScript/jQuery1.4.2.js" type="text/javascript"></script>
    <script src="../../JavaScript/EditInLine.js" type="text/javascript"></script>

 <script type="text/javascript">
  $(document).ready(function() {
   $('.editable').editable('/Home/Save', { 
        id        : 'editableId',
           name    : 'editableText',
     type      : 'textarea',
     cancel    : 'Cancel',
     submit    : 'OK',
     indicator : '<img src="img/indicator.gif">',
     tooltip   : 'Click to edit...',
     width     : '200',
     style     : 'display: inline',
     callbac   : function(value, settings) {
        alert(value);  
      return value;
    }

    });
  });
 </script>

</head>
<body>    


<label id='1' class='editable '>Some text</label>


</body>
</html>

and this my controller

using Castle.MonoRail.Framework;
using System;
using EditInLine.Model.Interfaces;
using EditInLine.Model;

namespace EditInLine.Controllers
{
    [Layout("Default"), Rescue("Default")]
    public class HomeController : SmartDispatcherController
    {
        private EditableElement editableElement;
        private EditableElement EditableElement
        {
            get
            {
                if (Session["EditableElement"] == null)
                {
                    Session["EditableElement"] = new EditableElement { Id = 1, Text = "Some text", CssClass = "editable" };
                }
                return (EditableElement)Session["EditableElement"];
            }            
        }


        public void Index()
        {
            PropertyBag["IsAdmin"] = true;
            PropertyBag["element"] = EditableElement;
        }

        public void Save()
        {
            var elementId = Convert.ToInt32(Request.Form["editableId"]);
            var text = Request.Form["editableText"];  

            var element = new EditableElement { Id = elementId, CssClass = "editable", Text = text };

            Session["EditableElement"] = element;            

        }


    }
}

thanks for you help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦冥 2024-10-03 21:20:41

Save() 的问题是您没有向浏览器返回字符串。通过 RenderText() 调用轻松修复。您还应该使用参数绑定,而不是弄乱 Request.Form

public void Save(int editableId, string editableText)
{
    var element = new EditableElement { Id = editableId, CssClass = "editable", Text = editableText};

    Session["EditableElement"] = element;

    RenderText(editableText);
}

The problem with Save() was that you did not return a string to the browser. Easily fixed with RenderText() call. You should also be using parameter binding instead of messing with Request.Form:

public void Save(int editableId, string editableText)
{
    var element = new EditableElement { Id = editableId, CssClass = "editable", Text = editableText};

    Session["EditableElement"] = element;

    RenderText(editableText);
}
太阳哥哥 2024-10-03 21:20:41

我找到了解决方案

public void Save()
        {
            var elementId = Convert.ToInt32(Request.Form["editableId"]);
            var text = Request.Form["editableText"];  

            var element = new EditableElement { Id = elementId, CssClass = "editable", Text = text };

            Session["EditableElement"] = element;            

 Response.Write(text);
 CancelView();
        }

I found the solution

public void Save()
        {
            var elementId = Convert.ToInt32(Request.Form["editableId"]);
            var text = Request.Form["editableText"];  

            var element = new EditableElement { Id = elementId, CssClass = "editable", Text = text };

            Session["EditableElement"] = element;            

 Response.Write(text);
 CancelView();
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文