• Resolved grincho

    (@grincho)


    Hi there,

    I try to run the editablegrid with sql on a Wp site. Out of the box, it works like charm but in WordPress i got the following error:
    SyntaxError: expected expression, got '<' in the editablegrid-2.1.0-b25.js

    functions.php of the child theme

    require_once( get_stylesheet_directory() . '/includes/adminUtils.php' );
    
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    
        wp_register_script( "editablegrid", get_stylesheet_directory_uri() .'/lib/editablegridSql/js/editablegrid-2.1.0-b25.js', array('jquery'), false, false );
        wp_register_script( "demo", get_stylesheet_directory_uri() .'/lib/editablegridSql/js/demo.js', array('jquery', 'editablegrid'), false, false );
        wp_enqueue_script( 'demo' );
        wp_localize_script( 'demo', 'myAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));
    }

    site:

    <div id="wrap">
        <h1>EditableGrid Demo - Database Link</h1> 
    
        <!-- Feedback message zone -->
        <div id="message"></div>
    
        <div id="toolbar">
            <input type="text" id="filter" name="filter" placeholder="Filter :type any text here"  />
            <a id="showaddformbutton" class="button green"><i class="fa fa-plus"></i> Add new row</a>
        </div>
        <!-- Grid contents -->
        <div id="tablecontent"></div>
    
        <!-- Paginator control -->
        <div id="paginator"></div>
    </div>
    <script type="text/javascript">var datagrid = new DatabaseGrid();(function($) {window.onload = function() { $("#filter").keyup(function() {datagrid.editableGrid.filter( $(this).val());});$("#showaddformbutton").click( function() {showAddForm();});$("#cancelbutton").click( function() {showAddForm();});$("#addbutton").click(function() {datagrid.addRow();});};})(jQuery);
    </script>
    <div id="addform">
        <div class="row">
            <input type="text" id="name" name="name" placeholder="name" />
        </div>
        <div class="row">
            <input type="text" id="firstname" name="firstname" placeholder="firstname" />
        </div>
        <div class="row tright">
            <a id="addbutton" class="button green" ><i class="fa fa-save"></i> Apply</a>
            <a id="cancelbutton" class="button delete">Cancel</a>
        </div>
    </div>

    If I don’t write the script code in one line, the error appears there. Ehm, is it normal that every line is wrapped in a <p> when wordpress generates the site?

    So hopefully someone can give me a hand or hint what I am doing wrong. Thanks.

    greetz

    Edit: the only active plugin: insert_php

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter grincho

    (@grincho)

    Edit: changed the js snippet code in the site. Formatted for better reading:

    <script>
    var datagrid = new DatabaseGrid();
    window.onload = function() {
      jQuery("#filter").keyup(function() {
        datagrid.editableGrid.filter(jQuery(this).val());
      });
      jQuery("#showaddformbutton").click( function() {
        showAddForm();
      });
      jQuery("#cancelbutton").click( function() {
        showAddForm();
      });
      jQuery("#addbutton").click(function() {
        datagrid.addRow();
      });
    };
    </script>

    Thread Starter grincho

    (@grincho)

    After one day ignoring it, I managed it to track it down.
    So work goes on …

    Moderator bcworkz

    (@bcworkz)

    Thanks for reporting back to us.

    If there’s anything else we can help you with… 😀

    [I jest of course, since we were no help at all]

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Include editablegrid into WordPress drama’ is closed to new replies.