cgull 25 Light Poster

Hello,

I am trying the example from Bootstrap 3 for nested columns.

The problem is, the nested row is going out of the parent column.

So this code:

<div class="row" style="border: 1px solid red">
  <div class="col-md-9">
    Level 1: .col-md-9
    <div class="row" style="border: 1px solid blue">
      <div class="col-md-6">
        Level 2: .col-md-6
      </div>
      <div class="col-md-6">
        Level 2: .col-md-6
      </div>
    </div>
  </div>
</div>

The row with the blue border starts about 10px outside of the row with the red border.

Screenshot attached.
d20ec268e4f6a5a1a03172c26601f453
Why is that?

cgull 25 Light Poster

Thank you.

cgull 25 Light Poster

Thank you, was just wondering if one has better performance than the other.

cgull 25 Light Poster

Hello,

I am developing a site where I have once class file that deals with a few database tables.

My question is:

Is it better to have one big file (the class) and then require only this file or have a class for each table and then have more require statements in my code?

Thank you

cgull 25 Light Poster

Ok, checked another option, and it looks like what's breaking the sort of the array is the jquery datatable plugin that I use. The array returned is in the right order, but dataTable breaks it.

cgull 25 Light Poster

Thanks, but that didn't help, I am still getting this result:
1
10
2
3
4
5
6
7
8
9

cgull 25 Light Poster

Hello,

I have an array that I need to sort by keys.

The array looks like this:

Array
(
    [0] => Array
    (
        [question_title] => Question 8
            [question_description] => 
            [type_id] => 1
            [type_title] => Yes/No
            [question_number] => 8
        )

    [1] => Array
(
    [question_title] => Question 9
            [question_description] => 
            [type_id] => 1
            [type_title] => Yes/No
            [question_number] => 9
        )

    [2] => Array
(
    [question_title] => Question 10
            [question_description] => 
            [type_id] => 1
            [type_title] => Yes/No
            [question_number] => 10
        )

    [3] => Array
(
    [question_title] => Question 11
            [question_description] => 
            [type_id] => 1
            [type_title] => Yes/No
            [question_number] => 11
        )

    [4] => Array
(
    [question_title] => Question 7
            [question_description] => 
            [type_id] => 1
            [type_title] => Yes/No
            [question_number] => 7
        )
)

I need to sort this array by question number, the problem is I get this result
1
10
11
2
3

I tried many many ways, nothing works.

For example I tried:

usort($questions, function($a, $b) {
  return (int) $a['question_number'] - (int) $b['question_number'];
});   

And:

foreach ($questions as $key => $row) {
  $mykey = (int) $row['question_number'];
  $volume[$mykey] = array(
              'question_title'=>$row['question_title'],
              'type_title'=>$row['type_title'],
              'question_number'=>$row['question_number']
              );
}

sort($volume, SORT_NUMERIC);
$questions = $volume;

And:

foreach ($questions as $key => $row) {
  $mykey = (int) $row['question_number'];
  $volume[$mykey] = array(
                       'question_title'=>$row['question_title'],
                       'type_title'=>$row['type_title'],
                       'question_number'=>$row['question_number']
                       );
  }

array_multisort($volume, SORT_NUMERIC, $questions);
$questions = $volume;

Nothing works.

Any suggestions?

Thank you

cgull 25 Light Poster

Another update:
I added the class dataTable to the table, now when I go to the page I get an alert error:

DataTables warning (table id='example'): Requested unknown parameter '1' from the data source for row 0

cgull 25 Light Poster

An update:

My table looks like this now:

<table class="display" id="example" border="0" cellpadding="0" cellspacing="0">
    <thead>
    <tr>
    <th colspan="1" class="ui-state-default" rowspan="2">
    <div class="DataTables_sort_wrapper">
    Match<span class="DataTables_sort_icon css_right ui-icon ui-icon-carat-2-n-s"></span></div>
    </th>
    <th rowspan="1" colspan="3" class="ui-state-default" style="text-align:center">Results
    </th>
    </tr>
    <tr>
    <th colspan="1" rowspan="1" class="ui-state-default">
    <div class="DataTables_sort_wrapper">
    Team<span class="DataTables_sort_icon css_right ui-icon ui-icon-triangle-1-s"></span></div>
    </th>
    <th colspan="1" rowspan="1" class="ui-state-default">
    <div class="DataTables_sort_wrapper">Halftime<span class="DataTables_sort_icon css_right ui-icon ui-icon-carat-2-n-s"></span>
    </div>
    </th>
    <th colspan="1" rowspan="1" class="ui-state-default">
    <div class="DataTables_sort_wrapper">Final Score<span class="DataTables_sort_icon css_right ui-icon ui-icon-carat-2-n-s"></span>
    </div>
    </th>
    </tr>
    </thead>
    <tbody>
    <tr>
       <td>

            PBHS vs St Stithians<br>
            24/03/2012
        </td>

    </tr>

    <tr>

        <td></td>
        <td>PBHS 1st</td>
        <td></td>
        <td>14</td>
    </tr>

    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <tr>

        <td>

            PBHS vs St Stithians<br>
            24/03/2012
        </td>
        ....

Now I see the show xx entries and the search box, but I see much more than just 10 rows in the table and I still can't sort any column.

cgull 25 Light Poster

Hello,

This is the first time I am trying to use jQuery DataTable.

I read a lot of articles, but I can't make it work.

I hope someone can help.

I need to build a table that displays Rugby games scores.
The table I am building should look like this:

<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
    <thead>
        <tr>
            <th>Match</th>
            <th colspan="3">Results</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <th></th>
            <th>Team</th>
            <th>Halftime</th>
            <th>Final Score</th>
        </tr>
        <tr>
            <td colspan="4">Match: AA</td>
        </tr>
        <tr>
            <td></td>
            <td>Team A</td>
            <td class="center">1</td>
            <td class="center">2</td>
        </tr>
        <tr>
            <td></td>
            <td>Team B</td>
            <td class="center">1</td>
            <td class="center">2</td>
        </tr>
        <tr>
            <td colspan="4">Match: BB</td>
        </tr>
        <tr>
            <td></td>
            <td>Team A</td>
            <td class="center">1</td>
            <td class="center">2</td>
        </tr>
        <tr>
            <td></td>
            <td>Team B</td>
            <td class="center">1</td>
            <td class="center">3</td>
        </tr>
    </tbody>
</table>

I want the user to be able to sort the columns:
Match, Team, Halftime and Final Score.

The way my code is now, the user can't sort on anything and the Show entries and search input field are not there at all.

My jQuery code:

$(function() {
        $('#example').dataTable({
            bJQueryUI: true
        });
    });

I include these two files on the page:
<link rel="stylesheet" href="/shared/jQuery/jquery-ui-1.10.3.custom/css/smoothness/jquery-ui-1.10.3.custom.min.css">
<script src="/shared/jQuery/jquery.dataTables.js"></script>

Can someone please help?

cgull 25 Light Poster

Hello,

I am having a strange behaviour with jQuery slideToggle.

When I click the link with class "tracking" I want the div under it to slide down if it is "closed" and up if it is "open"

The problem I have is that when I click the link, the div slides down, up and down again.

If I use just toggle it works fine. Why is that?

My code:

<div id="trackAjax">
  <a href="#" data-orderid="<?php echo $orderId; ?>" class="tracking">Enter Tracking No</a>

  <div id="trackingBox<?php echo $orderId; ?>" style="display:none">
    <?php 
      $attr = array('id'=>'trackForm');
      echo form_open($url, $attr);
    ?>
    <div class="control-group <?php if(form_error('tracking_no')) echo 'error'; ?>" style="margin-bottom:2px">
      <?php echo form_input(array('name'=>'tracking_no', 'class'=>'input-medium trackingNo', 'style'=>'margin-bottom:2px', 'value'=>set_value('tracking_no', $tracking_no))); ?>
      <span class="help-block"><?php echo form_error('tracking_no'); ?></span>
      <?php echo form_submit('submit', 'Save', 'class="btn"'); ?>
      <input type="hidden" name="submitted" value="1" />
    </div>

  </div>
  <?php echo form_close(); ?>
</div>
<script>
$(function()
{
  $('.tracking').on('click', function() {
    var id = $(this).data('orderid');
    $('#trackingBox'+id).slideToggle();
    return false;
 });
});
cgull 25 Light Poster

Ok, found the problem, it was the csrf.

I added my function in the config file:
$config['csrf_exclude_uris'] = array('cart/admin/orders/set_paid');

And everything is back to normal.

cgull 25 Light Poster

Thanks pritaeas, but I see this library is still in development so rather not use it.

cgull 25 Light Poster

Hello,

I am developing a site with ci 2.1.4

I used this tutorial to create an event in google calendar:
Click Here

When I change a date on the view, it calls the controller function with ajax, used to work fine, now the page just hangs and I can’t figure out what is going on.

My controller function (Calling create_event from the zend_helper):

public function set_paid()
 {
  $this->load->helper('zend');

  some code here....

  $title = $firstName . ' ' . $lastName . ' - order has been paid.';
  $where = 'Clarens';

  $content = "Order Details:\n";
  foreach($dets as $item)
  {
   $qty = $item['qty'];
   $coffee = $item['coffee'];
   $weight = $item['weight'];
   $content .= "Qty: $qty\nCoffee: $coffee\nWeight: $weight\n\n";
  }

  $content .= "Postage type: $postageType\n\n";
  $content .= "\nPostal Address:\n";

  foreach($addr as $item)
  {
   $addrLine1 = $item->addr_line_1;
   $addrLine2 = $item->addr_line_2;
   $suburb = $item->suburb;
   $city = $item->city;
   $postCode = $item->post_code;
   $province = $item->province;

   $content .= "$addrLine1\n";
   if($addrLine2)
    $content .= "$addrLine2\n";
   $content .= "$suburb\n$city $postCode\n$province"; 
  }

  create_event($title, $where, $content);

My zend helper:

<?php
//Changed this today, copied the Zend folder to application/libraries
/*if(ENVIRONMENT != 'production')
{
 ini_set("include_path", ini_get("include_path").PATH_SEPARATOR.str_replace("/", "\\", BASEPATH)."contrib\\");
 require_once ('Zend/Loader.php');
}
else
{
 ini_set("include_path", ini_get("include_path").PATH_SEPARATOR.BASEPATH."/contrib/");
 require_once 'Zend/Loader.php';
}*/
require_once (APPPATH . 'libraries/Zend/Loader.php');

function create_event($title, $where, $content)
{
 Zend_Loader::loadClass('Zend_Gdata_Calendar');
  Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
  // Parameters for ClientAuth authentication

 $user = "user";
 $pass = "pass";

 $service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
 $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
 $service = new Zend_Gdata_Calendar($client);

 // Create a new entry using the calendar service's magic factory method
 $event= $service->newEventEntry();

 // Populate the event with the desired information
 // …
cgull 25 Light Poster

My view IS php, I only posted the jquery part of it that was causing the problem.

cgull 25 Light Poster

Ok, changed this as well:
var postData = "type="+type + "orderId=" + orderId + "subtotal=" + subtotal;
To:
var postData = "type="+type + "&orderId=" + orderId + "&subtotal=" + subtotal;

Now it works, but the question is, is there no way to send the values without JSON and get the response as JSON?

cgull 25 Light Poster

Ok, found one problem:
alert(data.subtotal . ' ' . data.postage);
Changed to:
alert(data.subtotal + ' ' + data.postage);

So now the ajax call works, so now my code looks like this:

$.ajax({
            type: "POST",
        //  dataType: "json",
            //data: postData,
            data: { orderId: orderId, type: delivery_type, subtotal: subtotal },
            /*beforeSend: function(x) {
                    if(x && x.overrideMimeType) {
                            x.overrideMimeType("application/json;charset=UTF-8");
                    }
            },*/
            url: "<?php echo site_url('cart/calculate_delivery'); ?>",
            success: function(data)
            {
                    // 'data' is a JSON object which we can access directly.
                    // Evaluate the data.success member and do something appropriate...
                    alert(data.subtotal + ' ' + data.postage);
                    $('#delivery_cost').html(data.postage);
                    $('#total').html(data.total);
            }
        });

Alerting data.subtotal and data.postage I get:
undefined undefined

cgull 25 Light Poster

Tried that as well:

type: "POST",
        //  dataType: "json",
            //data: postData,
            data: { orderId: orderId, type: delivery_type, subtotal: subtotal },

Nada, nothing

cgull 25 Light Poster

Hello,

This is my first time trying to make an ajax call with JSON.

I am developing a site with CodeIgniter 2.1.4.

I am on the verge of throwing my computer away and find a job selling flowers....

Here's the story:

In my view I have a dropdown box:
<?php echo form_dropdown('delivery', $delivery, '1', 'id="delivery"'); ?>

When the user selectes a value in the dropdown box, I want to send some values to my controller and return some values.

In my view:

    $('#delivery').on('change', function()
    {
        var delivery_type = $(this).val();
        var orderId = $('#orderId').val();
        var subtotal = $('#subtotal').val();

        var postData = "type=" + delivery_type + "orderId=" + orderId + "subtotal=" + subtotal;
        alert(postData);

        $.ajax({
            type: "POST",
            dataType: "json",
            data: postData,

            beforeSend: function(x) {
                    if(x && x.overrideMimeType) {
                            x.overrideMimeType("application/json;charset=UTF-8");
                    }
            },
            url: "<?php echo site_url('cart/calculate_delivery'); ?>",
            success: function(data) {
                    // 'data' is a JSON object which we can access directly.
                    // Evaluate the data.success member and do something appropriate...
                    alert(data.subtotal . ' ' . data.postage);
                    $('#delivery_cost').html(data.postage);
                    $('#total').html(data.total);
            }
        });

        return false;
    });

It looks like the controller does not get all the posted values, so I am trying to test what is getting through.

My controller:

public function calculate_delivery($type=NULL)
    {
        if(!$type)
        {
            $ajax = TRUE; //Called from ajax, need to echo the result
            $type = $this->input->post('type');
        }
        else
        {
            $type = 2;
            $ajax = FALSE;//Not called from ajax, need to return the result
        }

        //Calculating postage
        $totalWeight = 0;
        $orderId = $this->get_open_order();
        $order = $this->order_dets_m->get_open_order($orderId);

        if($order)
        {
            foreach($order …
cgull 25 Light Poster

Hello,

I am looking at a git course and codeigniter best practice in tutsplus.

I am totally lost with all the installations I did since yesterday.

I installed git, cygwin and composer.

Now in the cygwin terminal I write: <code>composer -V</code> and I get my composer version.

Then I go to where my codeigniter site is installed: c:\sites\ci
And I put <code>echo @php "%~dp0composer.phar" %*>composer.bat</code> and I get the message: Could not open input file: composer.phar

Can you help please? I am totally confused with all these tools.

Do I need cygwin? I looked at google for hours and I just don't know where to go from here.

Can someone maybe help?

cgull 25 Light Poster

Ok, sorry, as you can see I try lots of things....

The folder is now in the public_html folder.

Now if I go to:
dev.mysite.co.za I get 404 Page not found

if I go to mysite.co.za/dev I get the Index of page.

What I really want is to get my index.php page that sits in: public_html/dev/public_html.... lol cry lol

cgull 25 Light Poster

Update:

I moved the dev folder to the root folder so now I actually have a sub domain...

But now When I go to: dev.mysite.co.za I get this default web page with instructions:

If you are the web site owner, it is possible you have reached this page because:

The IP address has changed.
There has been a server misconfiguration.
The site may have been moved to a different server.

I wrote my host, and will post here if I find the answer.

cgull 25 Light Poster

Hello,

I need help with htaccess and a sub domain.

I have a site I developed with ci 2.1.3

My folders structure is:
c:\sites\mysite
c:\sites\mysite\application
c:\sites\mysite\system
c:\sites\mysite\public_html\index.php
c:\sites\mysite\public_html\assets

In the public_html folder I have the htaccess file:

RewriteEngine On
RewriteCond $1 !^(index\.php|assets|images|robots\.txt|captcha)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 

Now I uploaded my site to the live server to a sub directory called: dev
I created a subdomain: dev.mysite.co.za

I uploaded all the files to the dev directory.

When I go to: dev.mysite.co.za

I get the page Index of with a list of the directories that are in the dev directory.

What do I need to do in order to see the site on the sub domain?

Can someone please help?

cgull 25 Light Poster

And I used to love Firefox.... lol

cgull 25 Light Poster

cereal, you found it! autocomplete, solved the problem.
I tested it on Chrome and it was fine without the autocomplete, but firefox needed it.
I just don't understand why does it happen only on this form and not on other forms in my app.
WOW, thank you very much.

cgull 25 Light Poster

Just one more thing, the strangest thing is, after I refresh the page, I look at the page source and the fields values are equal ''. For example:

<div class="control-group ">
    <label>Name *</label>
    <input type="text" name="author" value="" class="input-large"  />    <span class="help-block"></span>
  </div>

But on th page itself I see this: Name: cgull, which is the name I inserted into the field and then submitted the form.

The source says value = '' so how does it display cgull in the name field???

This is driving me nuts.

cgull 25 Light Poster

Hi cereal,

Sorry, I wasn't on my comupter the whole day.

My problem is that I submit the form successfuly. The input fields are cleared. Then I refresh the page, and the input fields have the values that I submitted in them again.

I will look at your code deeper tomorrow as I can't do it now.

Looked at it quickly and it is a bit different than my code, so I need to figure out why your code works and mine doesn't.

I will post here if I find the solution.

Thank you very much for all the effort.

cgull 25 Light Poster

Ok, I still have a problem, when I refresh the page, after submitting the form, the values are back in the input fields.... any idea how to fix that as well?

cgull 25 Light Poster

cereal you're a STAR !!!!

I've been struggling with this problem for days, posted about it all over the world, your solution sloved the problem.

I can't thank you enough !!!

THANK YOU ! :)

cgull 25 Light Poster

Hi cereal,

What it does is creating an object with the input fields and setting their values to blanks.