I have recently upgraded to cfwheels 2.2.0. I am attempting to upgrade my existing cfwheels app to add a new single-page-application that uses
ajax/json / jquery (maybe angularjs) .
1) Can someone provide me with a
/views/users/index.json.cfm
that uses the same data structure as on;
2) Also please provide an example of a "index() " for my /controller/users.cfc. Or does this look correct?
component extends="Controller" { function config() {
provides("html,json");
}
function index() {
// Define the local scope.
var LOCAL = {};
// Prepare the message for the user.
// Create new API response
LOCAL.AjaxResponse = {};
LOCAL.AjaxResponse["success"] = true;
LOCAL.AjaxResponse["errors"] = [];
LOCAL.AjaxResponse["data"] = model("user").findAll(returnAs="structs");
// Respond to all requests with `renderWith()`.
renderWith(data=
LOCAL.AjaxResponse , hideDebugInformation=true);
}
}
Thanks
Dan