React
1var Nav = ReactBootstrap.Nav; 2var NavItem = ReactBootstrap.NavItem; 3var activeNumber = 1; 4 5function handleSelect(selectedKey) { 6 alert('selected ' + selectedKey); 7 activeNumber = selectedKey; 8 console.log(activeNumber); 9 return activeNumber 10} 11 12const navInstance = ( 13 <Nav bsStyle="tabs" activeKey={1} onSelect={handleSelect}> 14 <NavItem eventKey={1} href="/home">NavItem 1 content</NavItem> 15 <NavItem eventKey={2} title="Item">NavItem 2 content</NavItem> 16 <NavItem eventKey={3} disabled>NavItem 3 content</NavItem> 17 </Nav> 18); 19 20ReactDOM.render(navInstance, document.getElementById('navi')); 21
###クリックしたらそのeventKeyを取得し(ここまではできている), const navInstance内にあるactiveKeyをその値に書き換えるというのをやりたい。
がしかし、activeKey の中にいれても動かないです。
AJAXを学び搭載すべく、JQUERYを使いたいのですが、
が、ajaxを採用するとしたら、どういうコードになりますか?
ちなみに、rails アプリの中で使用しようと考えておりますが、
もし実装しても、controllerを動かせば取得した値などが吹っ飛んでしまいそうに思いました・・・
やりたいことをまとめると
##Railsアプリの中でReactJSを使用したメニュータブの切り替えを行いたい。です。
あなたの回答
tips
プレビュー