I have a form which updates multiple records in a table and is working fine. I want too be able to add new records via ajax am loading the following in via ajax but am getting blackholed
<?
$uuid = String::uuid();
?>
<tr>
<?=$this->Form->input('Attachment.'.$uuid.'.id',array());?>
<?$this->Form->unlockField('Attachment.'.$uuid.'.id');?>
<td><?=$this->Form->input('Attachment.'.$uuid.'.title',array('label'=>false,'style'=>'float:left;'));?></td>
<?$this->Form->unlockField('Attachment.'.$uuid.'.title');?>
<td><?=$this->Form->input('Attachment.'.$uuid.'.url',array('label'=>false,'style'=>'float:left;'));?> <button onclick="return false;" class="btn attachment_select_file" style="float:left;"><i class="icon-folder-open"></button></i></td>
<?$this->Form->unlockField('Attachment.'.$uuid.'.url');?>
<td><button class="btn"><i class="icon-trash icon-large"></i></button></td>
</tr>
Does anyone have any idea what might be causing this.
Thanks
"There may be cases where you want to disable all security checks for an action (ex. ajax request). You may “unlock” these actions by listing them in $this->Security->unlockedActions in your beforeFilter." - from The cook book
The first thing I'd be doing is disabling the security component completely and seeing if that fixes it. If it does, then re-enable the security component, and add the relevant action to
$this->Security->unlockedActions
in your beforeFilter.
Related
In React I am creating a table with some inputs above it. The input fields are for filtering the table.
So I am wondering how the correct syntax would be for displaying the result from a form submit. I want this to be WCAG approved. Should I place the table just below the form? Or should i connect them in some way?
<form>
...
</form>
<table>
...
</table
And is it correct to place the input fields and the search button in a form? I would think so.
Thank you for any help!
It's fine to have both the form and the table on the same page.
The form itself should be accessible which means you'll need:
labels associated with each form element
appropriate handling of error messages
The table itself should be accessible which means you'll need:
proper table structure
use native <table>
use native <tr>
use native <th scope="col"> and <th scope="row">
use native <td>
And the final piece is the communication of when the filters are applied and the table updates. What happens visually? Is it just the contents of the table are updated? Do you have any other text on the screen that updates such as "X results found"?
If only the table updates, then you'll want to have a "hidden" message that is announced for screen reader users. Sighted users will see the table update but you should communicate that to non-visual users too. That can be done with "live" regions. It's pretty easy. You just have a container (<div>) that is visually hidden but can be updated with text. Something like:
<div class="sr-only" aria-live="polite">
</div>
When the table is updated, it would look like this:
<div class="sr-only" aria-live="polite">
Table has updated.
</div>
(The actual message should probably be better than that. Discuss that with your designer.)
The "sr-only" class is not something that is built in. You'd have to define it. That's just a common name to use for a class that is used to create text that is for "screen readers only" (sr-only). See What is sr-only in Bootstrap 3?
Is there any framework or technique to simply update data edited in table and stored in mongoDB
I am using angularjs, node.js and mongoDB.
My 'by hand' idea is to:
track edits in angular table that will return json with updated fields
send REST request for update edited fields with proper document id
Using the Angular JS, we can do all CRUD operation. For your question i have answer,
In HTML
<tr ng-repeat="list in getList">
<td>{{$index+1}}</td>
<td>{{list.firstname}}</td>
<td>{{list.lastname}}</td>
<td class=" last"><button type="button" class="fa fa-edit btn btn-primary" ng-click="edit($index,list)"></button>
</td>
</tr>
In controller,
$scope.edit=function(idx,list){
$scope.<name of ng-model>=angular.copy(list)
flag=idx;
}
and now in controller where to saving, check the data in save() function, where the list is existing in the table. If yes the call update(), else call add().
I can find plenty of examples on how to create a custom filter and using it for filtering a set of data.
However, I can't find any example on how to use a filter for filtering using a back-end service. For instance:
<input type="text" ng-model="query" />
<table id="searchTextResults">
<tr ng-repeat="item in items | filter:query">
results go here
</tr>
</table>
Instead of filtering the existing items, typing in the input should make a call to a service for getting results from the server. Does it make sense to use a filter in this case ? Or should I keep the logic in the controller ?
A filter would perform terribly in this situation as filters are executed as part of the each and every $digest loop. In practice it means that a given filter would be executed at least twice per $digest loop so you would have a mass of request to a back-end.
On top of this filters can't be really used reliably to fetch data from the server as filters execute synchronously while back-end calls are async.
In short - stay away from filters that trigger back-end calls.
I am developing a application in which one of my template renders a table with n number of rows. Now in each row, i have a column with buttons like edit and delete.
When clicked on edit, a edit form appears in the same window in some div. That form needs to be populated with values fetched from backend.
Now nothing great in this.
My problem is this:
I have a view which renders the complete table using the following template structure:
<script type="text/template" id="ledgersing">
<div class="span6 widget">
<div class="widget-header">
<span class="title">Ledgers</span>
<button class="btn btn-danger pull-right" id="addLedgerButton">Add Ledger</button>
</div>
<div class="widget-content">
<table width="100%" class="table table-striped dataTable">
<thead>
<tr><th>Name</th><th>Email</th><th>Phone</th><th>Action</th></tr>
</thead>
<tbody>
<% _.each(ledgers,function(data){ %>
<tr>
<td><%= data.name %></td>
<td><%= data.email %></td>
<td><%= data.contact_number %></td>
<td><span onClick="alert(<%= data.id %>)">x</span></td>
</tr>
<% }) %>
</tbody>
</table>
</div>
</div>
</div >
</script>
In this it just alerts a id when clicked on x. Now do i need to necessarily use onClick event like this? I mean that i will need the id in whatever construct i use for processing. What can be a better solution? I know backbonejs can handle this mess with ease if application is structured properly.
So essentially i want to know from experts, what will they do in such a scenario. How will they structure the application? I am novice to this frontend framework.
Instead of using _.each in your templates, I'd go with one view per table row as each one has some bit of complexity (edit, delete)
In these view, you use the events hash to register your DOM events. Never use onclick in your HTML, this is a really bad practice.
Don't hesitate to look at the TodoMVC Backbone example for ideas on how to organize your app.
I'm also developing a backbone application for the first time and went thru exactly the same mistake.
I first I just tried to translate my php / asp / ruby / whatever_server_side_template_technology into underscore templates, and got something pretty much like what you had.
Now I can realize it's a mistake. You should use subviews. The events and the associated model will be connected to that subview. Pretty soon you'll have lots of view listening to events and updating themselves when data changes, but if you're carefull it will be ok.
Here's a demo app I'm working on: https://bb-jugar.rhcloud.com/index.html#Wine
and here's the github repo: https://github.com/opensas/BackboneBootstrap
This is how I solved it: https://github.com/opensas/BackboneBootstrap/blob/master/demoapp/js/src/views/crud/RowsView.js
The model returns a list of beans which are displayed in a table using <c:forEach tag>. Some properties are of type input, so the user can edit these inline (optional).
The question is how to set a corresponding beanObject[by row index] when user clicks on checkbox? If clicked, then the appropriate bean needs to be updated via AJAX, I think.
So, how can we do that?
Normal Master-Detail approach has way too many clicks, that is why I need "update-able" tables.
Controller:
return new ModelAndView("daily","daily", dailyListOfBeansRecords;
Jspx:
form submit...
...
<c:forEach var="week" items="${Daily}" varStatus="loopIteratorValue">
<tr class="${loopIteratorValue.index % 2 == 0 ? 'd4' : 'd3'}">
<td><checkbox id="present" onchange="ProcessedUpdated(this,${loopIteratorValue.index})" value="${week.processed}"/></td>
</tr>
</c:forEach>
It seems to me you totally misunderstand jsp. jsp(x) is executed on the server side. you need javascript to do client-side processing.