We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19889
    • 616 Posts
    Hello
    I’m trying to paste the following content into a document - when saving the document I’m not getting the confirmation message and the regular manager screen but the document that I have been editing - the new content isn’t saved

    Could anybody please tell me what’s going on?
    <p><strong>"Unobtrusive JavaScript"</strong> is an emerging technique in the JavaScript programming language, as used on the World Wide Web. Though the term is not formally defined, its basic principles are generally understood to include:</p>
    <ul>
    	<li>Separation of functionality (the "behavior layer") from a Web page's structure/content and presentation</li>
    	<li>Best practices to avoid the problems of traditional JavaScript programming (such as browser inconsistencies and lack of scalability)</li>
    	<li>Progressive enhancement to support user agents that may not support advanced JavaScript functionality</li>
    </ul>
    <h3>The need for a new paradigm</h3>
    <p>JavaScript has long had a reputation as a clumsy, hackish language unsuitable for serious application development. This has been largely due to inconsistent implementations of the language itself and the Document Object Model in various browsers, and the widespread use of buggy cut-and-paste code. Runtime errors were so common (and so difficult to debug) that few programmers even tried to fix them, as long as the script behaved more or less the way it was supposed to - scripts often failed completely in some browsers.</p>
    <p>The recent emergence of standardized browsers, JavaScript frameworks and high-quality debugging tools have made organized, scalable JavaScript code possible, and the emergence of AJAX and Web 2.0 interfaces has made it essential.</p>
    <p>Whereas JavaScript was once reserved for relatively simple and non-critical tasks such as form validation and decorative novelties, it is now being used to write large, complex codebases that are often part of a site's core functionality. Runtime errors and unpredictable behavior are no longer minor annoyances; they are fatal flaws.</p>
    <p>Unobtrusive JavaScript can be seen as part of the larger Web standards movement; much as the demand for cross-browser compatibility has driven the increasing emphasis on standardized markup and style, the increasing demand for rich Internet applications is driving the movement toward the more robust methods of unobtrusive JavaScript. The term was invented in 2002 by Stuart Langridge.</p>
    <h3>Separation of behavior from markup</h3>
    <p>Traditionally, JavaScript often was placed inline together with an HTML document's markup. For example, the following is a typical implementation of JavaScript form validation when written inline:</p>
    <pre><code class="html"><input type="text" name="date" onchange="validateDate(this);" /></code>
    </pre>
    <p>However, the purpose of markup is to describe a document's structure, not its programmatic behavior. Combining the two negatively impacts a site's maintainability for the same reason that combining content and presentation does: if a site contains hundreds of such date fields, adding the appropriate <code>onchange</code> attribute for each one (and modifying them later, if necessary) can be a labor-intensive process.</p>
    <p>The unobtrusive solution is to register the necessary event handlers programmatically, rather than inline. This is commonly achieved by assigning a particular CSS selector to all elements which need to be acted upon by the script:</p>
    <pre><code class="html"><input type="text" name="date" /></code>
    </pre>
    <p>The script can then look for all input elements with the name <code>date</code>, and set them up accordingly:</p>
    <p>Using native JavaScript:</p>
    
    
    <pre><code class="js">window.onload = function(){ // Wait for the page to load.
        var inputs = document.getElementsByTagName('input');
        for(var i=0,l=inputs.length;i < l; i++){ 
            input = inputs[i];
            if(input.name && input.name=='date'){ 
                input.onchange = function(){ 
                    validateDate();
                }
            }
        }
    };
    
    function validateDate(){
    	/* Do something when the content of the 'input' element
    	with the name 'date' is changed. */
    }
    </code>
    </pre>
    
    <p>The following script is specific to the jQuery JavaScript library:</p>
    <pre><code class="html">$(document).ready(function(){ // Wait for the page to load.
    	$('input[name=date]').bind('change', validateDate);
    });
     
    function validateDate(){
    	/* Do something when the content of the 'input' element 
    	with the name 'date' is changed. */
    }
    </code>
    </pre>
    <p>Because the intended purpose of the <code>name</code> attribute is to describe the semantic role of an element, this approach is consistent with modern standards-based markup practices.</p>
    <p>The following script is specific to the MooTools JavaScript library:</p>
    <pre><code class="html">window.addEvent("domready",function() {
    	//code here will be executed when the dom has loaded
    })
    </code>
    </pre>
    <h3>Graceful degradation</h3>
    <p>This can be achieved by making sure links and forms can be resolved properly and rely not solely on Ajax. In JavaScript, e.g. a form submission can be halted by using "return false". If nothing goes wrong, Ajax code will be executed and the form submission will be skipped. If any problems occur with the user agent’s Ajax support or if the user does not have JavaScript enabled, the form will be submitted and the traditional version of the action will be performed.</p>
    <h3>Best practices</h3>
    <p>Though the essence of unobtrusive JavaScript is the concept of a separate behavior layer, advocates of the paradigm generally subscribe to a number of related principles, such as:</p>
    <ul>
    	<li>Strict adherence to the W3C DOM and event model, and avoidance of browser-specific extensions.</li>
    	<li>More generally, JavaScript best practices often parallel those in other programming languages, such as encapsulation and abstraction layers, avoidance of global variables, meaningful naming conventions, use of appropriate design patterns, and systematic testing. Such principles are essential to large-scale software development, but have not been widely observed in JavaScript programming in the past; their adoption is seen as an essential component of JavaScript's transition from a "toy" language to a tool for serious development.</li>
    </ul>
    <p><span class="source">Source: Wikipedia</span></p>
    


    • Which field are you pasting into? Content?

      Do you have TinyMCE enabled? Is RTF enabled for the page? What’s the content-type of the page?

      I might try turning off RTF and disabling TinyMCE then trying the paste/save again....
        • 19889
        • 616 Posts
        the content is set like all my other documents are set - text/html.

        I tried both - using RTE and without - the same result - I always get the real page back?
        • And TinyMCE? Was that disabled too?

          How about pasting only part of that content. Maybe paste 1 paragraph, then try 2 paragraphs, etc.. I seem to remember having an issue like that once... I could paste SOME content, but not other content.... I think it came down to TinyMCE freaking out at certain content.
            • 19889
            • 616 Posts
            This is really driving me nuts - I’ve a document with some content in it - if I like to add the following text to the existing content, MODx goes crazy again
            <p>This home is in the Hunters Ridge Plantation which combines 8 neighborhoods into one quiet secluded community. Conviently located 2 1/2 miles from either Hwy 501 or Hwy 544.</p>
            <p>Hunters Ridge is located close to:</p>


            it is not saving the newly added content and returns me the full page with all the layout instead of the manager screen.

            Tried to disable cache, tinyMCE etc., etc. - nothing seems to help.

            Still hope somebody has an idea where this is coming from?!

            Thanks
              • 21561
              • 16 Posts
              Have you check your System Info and System Events under the Reports Tab. There might be a clue there.

              I did paste your content into a page on my test site and it worked fine.
                • 19889
                • 616 Posts
                it works fine on my local installation as well - just problems on the server - system events doesn’t give a clue
                • Can you get the server logs, and especially any mod_security logs, for the relevant times? This almost sounds like some kind of paranoid (or badly configured) mod_security settings.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 19889
                    • 616 Posts
                    only have access to cpanel and I don’t see anything like this there - could it have anything to do with .htaccess and friendly urls?
                      • 10449
                      • 956 Posts
                      My bets are on mod_security as well. Ask the hosting company if they can send you the raw Apache logs.

                      see also http://wiki.modxcms.com/index.php/What_is_mod_security_and_how_does_it_affect_me + http://modxcms.com/forums/index.php?topic=29067.0