How to change the text on a button progamatically? |
Thanks for that. I am getting there (I think). I think I have the controller code OK. But the Jquery in the view is not working.
These two requirements are an issue: - The button or element the user must click, has the css class "show_campaign" and it has a data attribute: data-row_id="<?= $record['id'];?>"; - Within the same <tr></tr> tags, there is a button with the css class "btn-danger", which gets the new text from the AJAX function. I am using Grocery Crud and here is how the button is defined: $crud->add_action('Make Active', '\'http://www.grocerycrud.com/assets/upload...smiley.png\'', 'Configure/company_update','ui-icon-plus'); I don't need the smiley and will get rid of that. So when a user clicks the Make Active button, my controller code company_update() runs. In it I update the database and then, at the bottom of it have have echo $campaign. The code in the view (at the bottom of the body) has this: <script> $(document).ready(function(){ $('.show_campaign').click(function(){ cb = $(this); url = "<?= site_url('configure/campaign_update');?>"; rid = cb.data('row_id'); $.post( url, { row_id: rid }) .done(function(data) { cb.parent('tr').find('.btn-danger').text(data); }); }); }); </script> It is not working and I don't even know if it is getting fired since I can't put a breakpoint in it. Any idea how to debug the jquery code in the view? here is how the danger button in the view is defined: <button id="myCamp" class="btn pull-right btn-danger navbar-btn ">Active Campaign: None</button> Almost forgot, I am using Simplicity Codeigniter. Here is what the screen looks like:
proof that an old dog can learn new tricks
|
Welcome Guest, Not a member yet? Register Sign In |