onSelect of Mention component pass extra data

+ close #3867
This commit is contained in:
RaoHai 2016-11-16 17:16:32 +08:00
parent 200d3715e3
commit b0bdfcb94c
3 changed files with 5 additions and 5 deletions

View File

@ -27,8 +27,8 @@ const webFrameworks = [
{ name: 'Django', type: 'Python' },
];
function onSelect(suggestion) {
console.log('onSelect', suggestion);
function onSelect(suggestion, data) {
console.log('onSelect', suggestion, data);
}
const CustomNavMention = React.createClass({
getInitialState() {
@ -42,7 +42,7 @@ const CustomNavMention = React.createClass({
item.name.toLowerCase().indexOf(searchValue) !== -1
);
const suggestions = filtered.map(suggestion =>
<Nav value={suggestion.name} >
<Nav value={suggestion.name} data={suggestion}>
<span>{suggestion.name} - {suggestion.type} </span>
</Nav>);
this.setState({ suggestions });

View File

@ -36,7 +36,7 @@ When need to mention someone or something.
| suggestionStyle | style of suggestion container | Object | {} |
| onSearchChange | Callback function called when search content changes | function(value:String) | [] |
| onChange | Callback function called when content of input changes | function(editorState: EditorState) | null |
| onSelect | Callback function called when select from suggestions | function(suggestion: String) | null |
| onSelect | Callback function called when select from suggestions | function(suggestion: String, data?: object) | null |
| notFoundContent| suggestion when suggestions empty | string | '无匹配结果,轻敲空格完成输入' |
| loading | loading mode | boolean | false |
| multiLines | multilines mode | boolean | false |

View File

@ -36,7 +36,7 @@ title: Mention
| suggestionStyle | 弹出下拉框样式 | Object | {} |
| onSearchChange | 输入框中 @ 变化时回调 | function(value:String) | [] |
| onChange | 输入框内容变化时回调 | function(editorState: EditorState) | null |
| onSelect | 下拉框选择建议时回调 | function(suggestion: String) | null |
| onSelect | 下拉框选择建议时回调 | function(suggestion: String, data?: any) | null |
| notFoundContent| 未找到时的内容 | string | '无匹配结果,轻敲空格完成输入' |
| loading | 加载中 | boolean | false |
| multiLines | 多行模式 | boolean | false |