thedigicraft / Atom.CMS

Atom.CMS
56 stars 52 forks source link

Part 71 #49

Open writerman2160 opened 10 years ago

writerman2160 commented 10 years ago

Does not appear that Ajax is connecting. I have no errors popping up, but nothing is happening. Below are the pertinent pages... Everything was working fine up to Lesson 68. Was able to attach the buttons and the default, but nothing is happening after that point.

Thank You.

Patrick

pages.php|ajax

<?php

    include ('../../config/connection.php');

        $id = $_GET['id'];

        $q = "DELETE FROM pages WHERE id = $id";
        $r = mysqli_query($dbc, $q);

        if($r) {

            echo 'Page Deleted';

        } else {

            echo 'There was an error...<br>';
            echo $q.'<br>';
            echo mysqli_error($dbc);

        }

?>

pages.php|views

        <div class="row">

            <div class="col-md-1"></div>
            <div class="col-md-3">
                <h1>Page Manager</h1>
                <div class="list-group">

                <a class="list-group-item" href="?page=pages" ">
                    <i class="fa fa-plus"></i> New Page
                </a>                    

                <?php

                    $q = "SELECT * FROM pages ORDER BY title ASC";
                    $r = mysqli_query($dbc, $q);

                    while($list = mysqli_fetch_assoc($r)) { 

                        $blurb = substr(strip_tags($list['body']), 0, 160);        

                ?>

                    <div id="page_<?php echo $lists['id']; ?>" class="list-group-item <?php selected($list['id'], $opened['id'], 'active'); ?>">
                        <h4 class="list-group-item-heading"><?php echo $list['title']; ?>
                        <span class="pull-right">
                            <a href="#" id="del_<?php echo $lists['id']; ?>" class="btn btn-danger" btn-delete"><i class="fa fa-trash-o"></i></a>
                            <a  href="index.php?page=pages&id=<?php echo $list['id']; ?>" class="btn btn-default""><i class="fa fa-chevron-right"></i></a>
                            </span>
                            </h4>
                        <p class="list-group-item-text"><?php echo $blurb; ?></p>
                    </div>    

                <?php } ?>

                </div>

            </div>
            <div class="col-md-1">    </div>
            <div class="col-md-5">

                <?php if(isset($message)) { echo $message; } ?>

                <!-- Form Begins Here-->
        <form action="index.php?page=pages&id=<?php echo $opened['id']; ?>" method="post" role="form">

        <div class="form-group">

            <label for="title">Title:</label>
            <input class="form-control" type="text" name="title" id="title" value="<?php echo $opened['title'];  ?>" placeholder="Page Title" autocomplete="off">

        </div>

        <div class="form-group">

            <label for="user">User Name:</label>
            <select class="form-control" name="user" id="user">

                <option value="0">No user</option>

                <?php
                    $q = "SELECT id FROM users ORDER BY first ASC";
                    $r = mysqli_query($dbc, $q);

                    while ($list = mysqli_fetch_assoc($r)) { 

                        $user_data = data_user($dbc, $list['id']);
                    ?>

                    <option value = "<?php echo $user_data['id']; ?>" 

                        <?php
                            if(isset($_GET['id'])) {                                          
                            selected($user_data['id'], $opened['user'], 'selected');
                        } else { 

                            selected($userdata['id'], $user['id'], 'selected');
                            }
                        ?>> <?php echo $user_data['fullname']; ?></option>

                <?php } ?>

            </select>
        </div>
        <div class="form-group">
            <label for="slug">Slug:</label>
            <input class="form-control" type="text" name="slug" id="slug" value="<?php echo $opened['slug'];  ?>" placeholder="Page Slug" autocomplete="off">
        </div>

        <div class="form-group">
            <label for="label">Label:</label>
            <input class="form-control" type="text" name="label"  id="label" value="<?php echo $opened['label'];  ?>" placeholder="Page Label" autocomplete="off">
        </div>

        <div class="form-group">
            <label for="header">Header:</label>
            <input class="form-control" type="text" name="header" id="header"  value="<?php echo $opened['header'];  ?>" placeholder="Page Header" autocomplete="off">
        </div>

        <div class="form-group">
            <label for="body">Body:</label>
             <textarea class="form-control editor" name="body"  id="body" rows="8"><?php echo $opened['body'];  ?> </textarea>
        </div>

        <button type="submit" class="btn btn-default">Save</button> 
        <input type = "hidden" name="submitted" value="1">

        <?php if(isset($opened['id'])) { ?>
        <input type = "hidden" name="id" value = "<?php echo $opened['id']; ?>">
        <?php } ?>

    </form> 

            </div>

        </div>

js.php

<?php
    //javascript

    ?>

<!--jQuery-->
        <script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
        <!--jQuery UI-->
        <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

        <!-- Latest compiled and minified JavaScript -->
        <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>

        <script src="js/tinymce/tinymce.min.js"></script>

        <script>

        $(document).ready(function() {

            $("#console-debug").hide();

            $("#btn-debug").click(function(){

                $("#console-debug").toggle();

            });     

            $(".btn-delete").on("click", function(){

                var selected = $(this).attr("id");
                var pageid = selected.split("del_").join(""); //will find pageid and return an empty string..   

                $.get("ajax/pages.php?id="+pageid);

                $("#page_"+pageid).remove();

                //alert(selected);
            })

        });

                tinymce.init({
    selector: ".editor",
    theme: "modern",

    plugins: [
         "code advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
         "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
         "save table contextmenu directionality emoticons template paste textcolor"
   ],
   content_css: "css/content.css",
   toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | l      ink image | print preview media fullpage | forecolor backcolor emoticons", 
   style_formats: [
        {title: 'Bold text', inline: 'b'},
        {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
        {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
        {title: 'Example 1', inline: 'span', classes: 'example1'},
        {title: 'Example 2', inline: 'span', classes: 'example2'},
        {title: 'Table styles'},
        {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
    ]
 }); 

        </script>
thedigicraft commented 10 years ago

I found it!

Look in the form where you created the btn-delete button. You have a stray " in there.


<a href="#" id="del_<?php echo $lists['id']; ?>" class="btn btn-danger" btn-delete">

<a href="#" id="del_<?php echo $lists['id']; ?>" class="btn btn-danger btn-delete">
writerman2160 commented 10 years ago

Thank you.

Patrick


From: The Digital Craft notifications@github.com To: thedigicraft/Atom.CMS Atom.CMS@noreply.github.com Cc: writerman2160 patrick@denverwebspecialists.com Sent: Sunday, July 27, 2014 12:58 PM Subject: Re: [Atom.CMS] Part 71 (#49)

I found it! Look in the form where you created the btn-delete button. You have a stray " in there. <a href="#" id="del<?php echo $lists['id']; ?>" class="btn btn-danger" btn-delete"> <a href="#" id="del<?php echo $lists['id']; ?>" class="btn btn-danger btn-delete"> — Reply to this email directly or view it on GitHub.