I am trying to POST two pieces of data from an external webapp to OpenVBX.
calltonum:(phone number in format +12345678902)
callfromnum:(phone number in format +12345678902)
Once the data is in the app I am trying to use this feature: http://www.openvbx.org/docs/browserphone/api/
OpenVBX.clientDial({
'to': calltonum,
'callerid': callfromnum
});
I have verified this Javascript function works from a plugin, but havent been able to successfully post the data to a plugin yet. I was originally afraid I would run into authentication issues, but quickly found if I have an open session already and post data directly to a function inside a custom controller with a class that extends the User_Controller
... It receives the post data and passes it to the view just fine.
Right now, my issue is that when I load the view it populates great with all the CSS and Javascript and data view-able on the screen but then the page requests '/' to load which redirects the browser to /messages/inbox. I am also getting a js error:
Uncaught ReferenceError: $ is not defined(anonymous function) @ dosomethingplease:116
When trying to use the browserphone api leading me to believe jquery hasnt been loaded in the template.
Here is the code I currently have:
dialbrowser.php created in /controllers
<?php
class dialbrowserException extends Exception {}
class dialbrowser extends User_Controller {
public function __construct()
{
parent::__construct();
}
public function index()
{
return $this->dosomethingplease();
}
public function dosomethingplease()
{
$data = $this->init_view_data();
$this->template->add_js('assets/j/plugins/call-and-sms-dialogs.js');
$this->template->add_js('assets/j/frameworks/jquery-1.6.2.min.js');
$data = array('calltonum' => $this->input->post('calltonum'), 'callfromnum' => $this->input->post('callfromnum'));
$this->respond('title','dialnow', $data);
}
}
?>
dialnow.php created in /views
<div class="vbx-content-main">
<div class="vbx-content-menu vbx-content-menu-top">
<h2 class="vbx-content-heading">Test-a-roo</h2>
</div><!-- .vbx-content-menu -->
<div class="vbx-content-container">
<div class="vbx-content-section">
<div class="vbx-form">
<h3>Receipt of Number passed:</h3>
<div>
And here we made it the whole way.... didnt think we could do it huh?
<?php
echo "lets do this for sanity's sake... to: ".$calltonum." and from: ".$callfromnum." ...see no issues with the data!";
$html = "<script> $('document').ready(function(){OpenVBX.clientDial({'to': '".$calltonum."', 'callerid': '".$callfromnum."'});}); </script>";
echo $html;
?>
</div>
</div>
</div><!-- .vbx-content-section -->
</div><!-- .vbx-content-container -->
</div><!-- .vbx-content-main -->
and I can currently post to /dialbrowser/index or /dialbrowser/dosomethingplease successfully, and the data populates in the view.
What I don't understand is, why is it redirecting? And, since I am extending the User_Controller
shouldnt all the critical jquery/javascript already be loaded successfully?
UPDATE: I changed $route['dialbrowser'] = "dialbrowser";
in /config/routes.php
. It doesnt redirect at the controller level now! Now I can see the left menu is not there, the call button has no functionality, and the previous javascript error still persists.