⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Unique_Hash not defined



bazianm

bazianm
  • profile picture
  • Member

Posted 21 June 2012 - 13:33 PM

Hi,

I am new to Grocery_CRUD and, to begin with, I think this is great stuff. I am also somewhat new to web development, php and CodeIgniter so this tool is a real plus!

I am having an issue and I am not sure what I am doing wrong. I am following the "Full Example". I get an error on the edit screen (shown in FireBug) that:

unique_hash is not defined
http://devtest/assets/grocery_crud/themes/flexigrid/js/flexigrid.js
Line 153


I am guess this is what is causing problems with the buttons on the entry form not working properly but I have no idea what is causing it. Here is what I am loading:

<html>
<head>
<meta content="Content-Type">
<link rel="/css/basestyles.css" type="screen,projection">
<link rel="/css/smoothness/jquery-ui-1.8.21.custom.css" type="screen,projection">
<link rel="/css/1140.css" type="screen" />
<link rel="/css/menustyles.css" type="screen,projection">
<link rel="/assets/grocery_crud/themes/flexigrid/css/flexigrid.css" type="text/javascript" src="/js/jQuery.js"></script>
<script src="/assets/grocery_crud/themes/flexigrid/js/jquery.form.js"></script>
<script src="/assets/grocery_crud/themes/flexigrid/js/jquery.numeric.js"></script>
<script src="/assets/grocery_crud/themes/flexigrid/js/cookies.js"></script>
<script src="/assets/grocery_crud/themes/flexigrid/js/flexigrid.js"></script>

<title>Stores</title>
</head>


Any assistance would be greatly appreciated.

Thanks

web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 21 June 2012 - 22:40 PM

Did you try to go step by step at: http://www.grocerycrud.com/documentation/create-crud-codeigniter-tutorial ? . It seems that you haven't loaded the javascript and the css needed. You have to add this to your template:


<?php
foreach($css_files as $file): ?>
<link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />

<?php endforeach; ?>
<?php foreach($js_files as $file): ?>

<script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>


If you already have a jquery included to your template you will just need the:


$crud->unset_jquery();


I think if you just follow step by step the instructions you will not have any problem with this.

amityweb

amityweb
  • profile picture
  • Member

Posted 23 July 2012 - 16:08 PM

Hi johnny

I am having this issue too... but what I have done is add my own JS and CSS files. I copied the ones from Grocery Crud into my own arrays. I did this because I have some pages that are not GroceryCrud pages and wanted to get the CSS and JS files on there to use. But I could not see another way other than setting them myself.

But by manually creating the js_array and css_array it seems to break it? Is it because this unique_hash is not in the array as a key? Can we insert that manually too?

Thanks

web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 23 July 2012 - 21:43 PM

Hello [member='amityweb']

You can add this code to your JavaScript to prevent the errors:

var ajax_list_info_url = '/your_custom/path/to/ajax'; //Here you will add the AJAX call for paging/sorting and searching.
var unique_hash = 'SomethingRandom';
var message_alert_delete = "Are you sure you want to delete it?";


You will not have any errors [b]however[/b] it will take a while to create the logic for the AJAX queries. When I created grocery CRUD there was not any jquery plugin for flexigrid so I created flexigrid.js from scratch for the needs of grocery CRUD. In addition I don't think that it is a good idea to take the JavaScript from grocery CRUD and try to add it to another view.

The solution that I am suggesting is to go to http://flexigrid.info/ and read the instructions of how to add flexigrid to your project with Jquery. I think this is the best solution for now. If you still want to integrate the CSS and JS of grocery CRUD of course I can help you with this if you want but I believe it will take more time than to add flexigrid from scratch.

Kindest Regards
Johnny

amityweb

amityweb
  • profile picture
  • Member

Posted 23 July 2012 - 22:01 PM

I have had some issues doing what I wanted... basically I have a non-GroceryCrud query and table output, that I wanted to style and make work like Flexigrid. I thought I could use the same code. But I can see your Flexigrid is different from the original one. So therefore I agree with you, best not to do this. I have reverted back, and looks like I should install Flexigrid as a seperate add-on for my non-Grocerycrud data.

I can also see Grocerycrud dynamically adds JS depending on the fields in the table. So I wont do this now.

Thanks for your advice