I Try tutorial from http://www.jeasyui.com/tutorial/datagrid/datagrid24.php
I create this function in mycontroller..
function doSearch(){
$('#tt').datagrid('load',{
itemid: $('#itemid').val(),
productid: $('#productid').val()
});
}
I get error message like this..
Parse error: parse error, expecting T_VARIABLE' or'$'' in C:\xampp\htdocs\ci_jquery\application\controllers\crud.php on line 55
I dont know, how to create that function in controller codeigniter.
Thanks For The Reply..
Your problem is that the code which you've posted is not PHP code, it's Javascript code (more specifically, it belongs to the jQuery framework). It does not need to live in a controller, but instead should be added to the view, where your HTML content is.
You first need to load a view file, and then add the code above into it.
$this->load->view('myview');
You would then have to add the Javascript code which you've posted into your view file (in the example I've provided, that would be in application/views/myview.php. Make sure to also include the jQuery library in your template!
You can read more on views here: http://ellislab.com/codeigniter/user-guide/general/views.html
Related
I am calling wordpress's tinyMCE from php and assigning it's contents through ajax to a form array key.
I keep on getting error: Cannot read property 'getContent' of null.
I read thought Wordpress wp_editor() not working and Include TinyMCE plugins with Wordpress wp_editor? & others but still can't get tinyMCE's content into form array.
JS:
var form = {
action: "submit_user_data",
content: tinymce.activeEditor.getContent(),
title: $("#inputTitle").val(),
ingredients: $("#inputIngredients").val(),
time: $("#inputTime").val(),
utensils: $("#inputUtensils").val(),
level: $("#inputLevel").val(),
meal_type: $("#inputMealType").val()
};
PHP:
wp_editor( '', 'tinymcecontenteditor' );
The issue is originated at the tinymce.activeEditor.getContent() call.
Any ideas?
Thanx
Following through on the call to 'tinymce's methods & functions, I could not find anything wrong with the call.
But somehow (still can't figure it out do this one's left for the public) I noticed that calling tinymce from a jquery as mentioned does not give access to it's contents (obviously...dah..).
What I found out I need to do is, instead of calling the getContent function, I had to trigger the triggerSave function and the get the val of the object by id, so:
tinyMCE.triggerSave();
var contents = $("#tinymcecontenteditor").val();
Before I assign it's contents to the form array.
Form array changed to content: contents,.
shahnbaz's answer pointed me in that direction.
Sounds like the problem lies with your WordPress integration. As long as the TinyMCE JS is in the page, activeEditor should always return the editor instance.
I am very new to PHP , but i want to show a html page and handle it with and .php file in codeigniter, How can i do it.
Example could be like this :
http://www.w3schools.com/php/showphp.asp?filename=demo_form_post
I tried to do the same but in controller if i try to run the html file it works fine but as i click on submit and try to fetch values it give my errors.
i do:
1. Made 2 file in view namely: Test.html and Test_Values.php
in Test.html i keep : the code as mentioned in w3 link
and in Test_Value.php I wrote the logic.
2.In controller i calls : $this->load->view("Test.html");
it shows me my html page but as i click on the submit button it says 404 page not found.
Please help me. What am i doing wrong??
Firstly you will have to put your logic in a function in your controller and not a separate .php file. e.g:
class Yourcontrollername extends CI_Controller{
...
function form_processor(){...}
}
Then You are supposed to give the address and the name of the function which is going to process the form you sumbitted in the action attribute of your form! e.g:
<form action="yourControllerName/form_processor" method="post">
Finally, you really need to have to study the Codeigniter Manual
I am trying to load a specific portion of an article with using of jquery load() function when a tab is clicked. The tab is inside an article and trying to show another article within the first article from where the tab is being clicked. The jquery code I have put inside the template.php of choosen template. The main problem is that when I click nothing is comming inside the first article under the tab. I am using joomla2.5.11 version. Please give some suggestion.The jquery code what I am trying is shown below:
$(function(){
$("h3.menuheader").click(function(){
$(".active-tab").removeClass("active-tab");
$(this).addClass("active-tab");
$(".tabcontent-ul").slideUp();
$(".tabcontent").load("http://www.mpsinfoservices.com/projects/teamzstudio/web-application-development#link1",function(){
$(".tabcontent").slideToggle();
});
});
});
Unfortunately I don't think you've provided enough to diagnose this issue. But perhaps I can help with how I would diagnose.
To start with, try this instead:
// http://www.mpsinfoservices.com/projects/teamzstudio/web-application-development#link1
$(".tabcontent").load("http://www.google.co.uk",function(){
$(".tabcontent").slideToggle();
});
Then open up your developer tools and see if a call is being made to load that data.
If it is, then you need to consider that it might be loading the data and putting it in another element you can't see.
So to test, create a new container on the page near your footer, which you know will be visible with a specific #ID like <div id="testID"></div> and load into that. Once that is working, look to confirm your .tabcontent element is the one you want using something like console.log().
I have a form at the bottom of a long page, if a user fills out the form but it doesn't validate the page is reloaded in the typical codeigniter fashion:
$this->load->view('template',$data);
however because the form is way down at the bottom of the page I need the page to load down there like you do with HTML anchors. Does anyone know how to do this in codeigniter?
I can't use the codeigniter
redirect();
function because it loses the object and the validation errors are gone. Other frameworks I've used like Yii you can call the redirect function like:
$this->redirect();
which solves the problem because you keep the object. I've tried using:
$this->index()
within the controller which works fine as a redirect but the validation errors are in another method which is where the current page is loaded from:
$this->item($labs)
but when I use this it get stuck in a loop
Any ideas? I've seen this question a lot on the net but no clear answers. I'm researching using codeigniter "flash data" but think it's a bit overkill.
cheers.
I can't personally vouch for this, but according to this thread if you append the anchor to the form's action, it will work.
CodeIgniter helper:
<?php echo form_open('controller/function#anchor'); ?>
Or vanilla HTML:
<form method='post' action='controller/function#anchor'>
If you were open to using Javascript, you could easily detect a $validation_failed variable and appropriately scroll. Or, even better, use AJAX.
Another option is to put the form near the top of the page?
Ok, as far as I understood your problem, it isn't much related to the back end(codeigniter). You want the form at the bottom of the page to be 'what-users-sees-on-page-load' (since you mention anchors).
Now, what you can do is, you can set delimiters for your validation error messages using:
echo validation_errors('<div id="bottom_form_error">', '</div>');
Using jQuery ScrollTo, do:
$( function() { $('#bottom_form_error').ScrollTo(); } );
And, the user will be scrolled to the errors at the bottom of the page. Don't forget to include jQuery too.
Anchor hash fragment click is different - it is scrolling at ∞ speed.
I hope that is what you wanted.
P.S. I am ignoring what you said below this line:
Does anyone know how to do this in codeigniter?
as I felt it is not really relevant to the question.
i am new to smarty template and i am trying to do this.
I have a html form in the tpl file and in that form action is for a php email function email.php. I am not able to get it to work. if i have the complete code(html form + php email code) and save as a php file, it works fine.
is there any way to call the php code from email.php inside that tpl file? i am completely new and i am just making some changes on the site.
regards
after doing some google search, i found that i can do this way
In the tpl(ex - mail.tpl)
{ php }
//all php code here, in my case its the mailer
{ /php }
and in the form action, just give "mail.tpl" .
fyi, i designed this contact with ajax way to just do the submission in the same page without navigating.
{php}{/php} is deprecated in Smarty V3 now