开发者

Jeditable Problem in castle monorail

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

I managed to have the te开发者_JAVA百科xtbox 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


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);
}


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();
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜