Welcome Guest, Not a member yet? Register   Sign In
Bonfire Tutorial
#1

[eluser]kilishan[/eluser]
Included in latest version of the docs that ship with Bonfire is a simple tutorial for creating a ToDo module. It steps you through all of the basics that you need to understand to start creating Bonfire modules.

The website has been updated with the latest version of the docs, so you can also view the tutorial online.
#2

[eluser]HeartlandTech[/eluser]
I just installed this and I'm trying to go through the doc files on the todo list. Is this right???

<?php echo form_open('/admin/content/todo/delete', 'class="ajax-form"'); ?>

Because down here:

[removed]
head.ready(function() {
$('#task-form input[type=checkbox]').change(function() {
var cid = $(this).attr('data-id');

// Remove it from the display, with a fade effect
$(this).parents('tr').fadeOut(300);

// Tell the server to remove it.
$.post('/admin/content/todo/delete/'+ cid);
});
});
[removed]
#3

[eluser]HeartlandTech[/eluser]
I made a few changes to the tutorial on the todo items. Notably I fixed the javascript - you were using # instead of . for the class. I also changed the name, you were using "ajax-form" and "todo-form". I also fixed the delete as I was using it in a directory called "bonfire" (from the install/rename) and it was trying to navigate further up the tree.


Code:
<br/>
&lt;?php if (auth_errors() || validation_errors()) : ?&gt;
<div class="notification error">
  &lt;?php echo auth_errors() . validation_errors(); ?&gt;
</div>
&lt;?php endif; ?&gt;

&lt;?php echo form_open(current_url(), 'style="max-width: 700px"') ?&gt;

  Todo: &lt;input type="text" name="description" placeholder="What Do You Need To Do?" value="" /&gt;

  <div class="submits">
      &lt;input type="submit" name="submit" value="Create New Item" /&gt;
  </div>

&lt;?php echo form_close(); ?&gt;


&lt;?php if (isset($items) && is_array($items) && count($items)) : ?&gt;
<h3>ToDo Items</h3>

&lt;?php echo form_open('/admin/content/todo/delete', 'class="todo-form"'); ?&gt;
<table>
  <tbody>
  &lt;?php foreach ($items as $item) : ?&gt;
      <tr>
          <td style="width: 1em; text-align: center">
              &lt;input type="checkbox" name="items[]" value="1" data-id="&lt;?php echo $item-&gt;todo_id ?&gt;" />
          </td>
          <td>&lt;?php echo $item->description ?&gt;</td>
      </tr>
  &lt;?php endforeach; ?&gt;
  </tbody>
</table>
&lt;?php echo form_close(); ?&gt;

&lt;?php endif; ?&gt;


[removed]
head.ready(function() {

    
  $('.todo-form input[type=checkbox]').change(function() {
    
      var cid = $(this).attr('data-id');
      
      // Remove it from the display, with a fade effect
      $(this).parents('tr').fadeOut(300);

      // Tell the server to remove it.
      $.post('&lt;?php echo current_url();?&gt;/delete/'+ cid);
  });
});
[removed]
#4

[eluser]kilishan[/eluser]
That's what I get for doing this tutorial in small bursts as I could squeeze in the time. Thought I had everything corrected as I was making changes to the code. Obviously not!

Thanks for these. I'll get them added to the tutorial and posted on the site.




Theme © iAndrew 2016 - Forum software by © MyBB