I have an edit-in-place (jEditable) dropdown list of categories. One of the options is "New Category".
If a user selects "New Category" and submits the form using Ajax I want PHP to trigger a jQuery function which opens an overlay dialog box and prompts the user for input.
How can I get PHP to trigger the jQuery function?
PHP Code...
function update()
{
$id = $this->input->post('id');
$value = $this->input->post('value');
$data = array('category_id' => $value );
$this->db->where('id', $id);
$this->db->update('transactions', $data);
$category = new Category();
$category->where(array('id' => $value));
$category->get();
if ($value == 0) {
// Trigger jQuery function
} else {
echo $category->name;
}
}
The jQuery function I want to trigger (It's currently triggered via a button)...
//===== UI dialog =====//
$( "#new-cat-input" ).dialog({
autoOpen: false,
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
$( "#open-new-cat" ).click(function() {
$( "#new-cat-input" ).dialog( "open" );
return false;
});