react-rails

Get Selected option attribute in React

孤人 提交于 2020-06-11 03:16:03
问题 I want to get attribute from my select option list. In meanwhile my code is like below : var Billing = React.createClass({ getInitialState() { return { associations: [], value: '', associationsList: '1' }; }, handleChange(event) { this.setState({value: event.target.value}); }, handleOption(event){ var option = event.target.getAttribute('data-id'); this.setState({associationsList: option}); }, render() { var listAssociations = this.state.associations.map(function(index){ return ( <option

Get Selected option attribute in React

牧云@^-^@ 提交于 2020-06-11 03:15:28
问题 I want to get attribute from my select option list. In meanwhile my code is like below : var Billing = React.createClass({ getInitialState() { return { associations: [], value: '', associationsList: '1' }; }, handleChange(event) { this.setState({value: event.target.value}); }, handleOption(event){ var option = event.target.getAttribute('data-id'); this.setState({associationsList: option}); }, render() { var listAssociations = this.state.associations.map(function(index){ return ( <option

Warning: input is a void element tag and must not have `children` or use `props.dangerouslySetInnerHTML`. Check the render method of null

柔情痞子 提交于 2020-01-13 09:30:08
问题 I am trying to render the errors in the form if the ajax call to the form URL fails. Below is my Admin component: #app/assets/javascripts/components/admin.js.coffee @Admin = React.createClass # propTypes: -> # emailVal: React.PropTypes.string.isRequired getInitialState: -> edit: false errorTexts: [] handleToggle: (e) -> e.preventDefault() @setState edit: !@state.edit @setState errorTexts: [] handleDelete: (e) -> e.preventDefault() # yeah... jQuery doesn't have a $.delete shortcut method $

Input field doesn't receive keyboard events when rendering with value property?

可紊 提交于 2020-01-02 21:47:31
问题 I am using react-rails gem to work with ReactJS for Rails. The weird thing is if I set a non-empty value property when rendering React component, the input field won't receive any keyboard event This doesn't work! React.DOM.input type: 'text' className: 'form-control' value: "ABC" But it works React.DOM.input type: 'text' className: 'form-control' value: "" Any idea guys? Thanks a lot! 回答1: I have answered to one question similar to this, i don't know how to share that answer to you. So i am

How to call another component from onClick function in ReactJS

扶醉桌前 提交于 2019-12-31 17:58:48
问题 I am learning Reactjs. I have implemented one sample react app with rails. I have search a lots to find the solution but I didn't find any. I wanted to call another component from onClick function. But nothing happen. Is that possible what I try to achieve? If yes, then please point me where I do mistake and If not, then which way I can implement. Here is my code: var Comment = React.createClass({ render: function () { return ( <div id={"comment_"+ this.props.id }> <h4>{ this.props.author }

How to call another component from onClick function in ReactJS

Deadly 提交于 2019-12-31 17:56:13
问题 I am learning Reactjs. I have implemented one sample react app with rails. I have search a lots to find the solution but I didn't find any. I wanted to call another component from onClick function. But nothing happen. Is that possible what I try to achieve? If yes, then please point me where I do mistake and If not, then which way I can implement. Here is my code: var Comment = React.createClass({ render: function () { return ( <div id={"comment_"+ this.props.id }> <h4>{ this.props.author }

ReactDnD: “Invariant Violation: addComponentAsRefTo” Error

大城市里の小女人 提交于 2019-12-24 15:49:39
问题 Dear people of StackOverflow, I am trying to implement Drag and Drop functionality in a React-Rails app. However, as soon as I add the DragDropContext to the top level component, I see this error in the browser console: 'react.self-0f0e88a….js?body=1:1087 Uncaught Error: Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component's render method, or you have multiple copies of React loaded'

Rails CORS issue with Ajax API endpoint Request

萝らか妹 提交于 2019-12-20 06:29:39
问题 I seem to be running into some issues making a GET request to an API endpoint. I know rails has some security going on behind the scenes. I'm using React-Rails and in my componentDidMount to make an ajax call to an API endpoint. I am passing in a X-Auth-Token in my headers too. My console error: XMLHttpRequest cannot load "/api/end/point..." Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin

How to eager load associations into an instance variable?

这一生的挚爱 提交于 2019-12-13 06:46:54
问题 In Model I have: class CalendarItem < Resource belongs_to :schedule has_many :people has_many :documents acts_as_list scope: :schedule, column: :visual_position validates :schedule, :title, presence: true end Then in controller: class ScheduleController < ApplicationController def show @calendar_items = CalendarItem.where(schedule: @schedule).includes(:people, :documents) end ... end In the view I'm rendering a react_component with react-rails (but that should make any difference): = react

How to call react-modal from rails-assets.org in react-rails component

一笑奈何 提交于 2019-12-12 16:32:54
问题 I have a rails app that uses react on the front end but I'm having trouble adding other react modules to my components. I am using react-rails for incorporating react into my rails app. I would like to add react-modal to a component. I've used rails-assets to add react-modal as a gem but I'm having trouble calling react-modal in my component. I was hoping it would be a similiar call as React.DOM but that hasn't seemed to be the case. I can't use the normal 'require()' syntax due to sprockets