Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. var React = require('react');
  2. var SelectPolicies = require('../components/SelectPolicies.react');
  3. var CustomerStore = require('../stores/CustomerStore');
  4. var CustomerRepository = require('../repositories/CustomerRepository');
  5.  
  6. var SelectPoliciesController = React.createClass({
  7. displayName: "SelectPoliciesController.react",
  8. componentWillMount: function () {
  9. //initiate ajax call
  10. CustomerRepository.getCustomer();
  11. return true;
  12. },
  13.  
  14. var CustomerRepository = {
  15.  
  16. getCustomer: function() {
  17. var xhr = new XMLHttpRequest();
  18. xhr.open("get", "/api/customer", true);
  19. xhr.onload = function () {
  20.  
  21. var customer = JSON.parse(xhr.responseText);
  22. Actions.receiveCustomer(customer);
  23.  
  24. }.bind(this);
  25. xhr.send();
  26. }
  27. }
  28.  
  29. var AppDispatcher = require('../dispatcher/AppDispatcher');
  30. var AppConstants = require('../constants/AppConstants');
  31.  
  32. var CustomerActions = {
  33.  
  34. receiveCustomer: function (customer) {
  35.  
  36. var action = {
  37. actionType: AppConstants.RECEIVE_CUSTOMER,
  38. customer: customer
  39. };
  40. AppDispatcher.dispatch(action);
  41. },
  42. };
  43.  
  44. module.exports = CustomerActions;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement