简体   繁体   中英

Vitalets x-editable not working

I want to implement vitalets x-editable with my c# asp application, but I am encountering some difficulties. After I make the javascript configurations to appear like a link, it just refreshes the page and goes to the '#'. I have intalled the packeage of the vitalets through the command line " install-package x-editable " and copied the Javascript folder in the script folder in my application (the js source http://vitalets.github.io/x-editable/assets/zip/jqueryui-editable-1.5.1.zip ). Currently to test it with simple HTML to see it functioning I tried this simple html code:

<!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="utf-8">
        <title></title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <link href="//cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/jqueryui-editable/css/jqueryui-editable.css" rel="stylesheet"/>
        <script src="//cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/jqueryui-editable/js/jqueryui-editable.min.js"></script>
      </head>
      <body>
        <div class="container">
          <h1>Template</h1>
          <div>
            <span>Username:</span>
            <a href="#" id="username" data-type="text" data-pk="1">Old username</a>
            <script>
            $.fn.editable.defaults.mode = 'inline';
            $('#username').editable();
                $(function(){
                    $('#username').editable({
                        type: 'text',
                        url: '/post',
                        title: 'Enter username'
                    });
                });
            </script>
          </div>
        </div>
      </body>
    </html>

This code does the same effect as my asp code, it just redirects to the '#' and doesn't show anything. Am I missing some other configuration or lines to make it correct? I am quite new to javascript and x-editable. if you could post some plain example would be appreciated.

Thanks

It has passed a lot since the question, and I haven't posted the solution I improvised. The problem was caused in my asp code by the update panels. I was using it in a gridview and after the databind, the vitalets functionality was lost, since the postback recreated the controls within the update panel. I fixed it by reassigning it on a pageLoad javascript function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM