文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
回调函数
# Functions set for handling and rendering the data. # Others developers can override these methods to tweak At.js such as matcher. # We can override them in `callbacks` settings. # # @mixin # # The context of these functions is `$.atwho.Controller` object and they are called in this sequences: # # [beforeSave, matcher, filter, remoteFilter, afterMatchFailed, sorter, tplEval, highlighter, beforeReposition, beforeInsert, ] # DEFAULT_CALLBACKS = # It would be called to restructure the data before At.js invokes `Model#save` to save data # In default, At.js will convert it to a Hash Array. # # @param data [Array] data to refacotor. # @return [Array] Data after refactor. beforeSave: (data) -> # It would be called to match the `flag`. # It will match at start of line or after whitespace # # @param flag [String] current `flag` ("@", etc) # @param subtext [String] Text from start to current caret position. # # @return [String | null] Matched result. matcher: (flag, subtext, should_startWithSpace, acceptSpaceBar) -> # --------------------- # Filter data by matched string. # # @param query [String] Matched string. # @param data [Array] data list # @param searchKey [String] at char for searching. # # @return [Array] result data. filter: (query, data, searchKey) -> # If a function is given, At.js will invoke it if local filter can not find any data # # @param params [String] matched query # @param callback [Function] callback to render page. remoteFilter: null # remoteFilter: (query, callback) -> # $.ajax url, # data: params # success: (data) -> # callback(data) # Sorter data of course. # # @param query [String] matched string # @param items [Array] data that was refactored # @param searchKey [String] at char to search # # @return [Array] sorted data sorter: (query, items, searchKey) -> # Eval template for every single item in display list. # # @param tpl [String] The template string. # @param map [Hash] Data map to eval. # # @return [String] the composed display data tplEval: (tpl, map) -> # Highlight the `matched query` string. # # @param li [String] HTML String after eval. # @param query [String] matched query. # # @return [String] highlighted string. highlighter: (li, query) -> # What to do before inserting item's value into inputor. # # @param value [String] content to insert # @param $li [jQuery Object] the chosen item # # @return [String] altered content to insert. beforeInsert: (value, $li) -> # You can adjust the menu's offset here. # # @param offset [Hash] offset will be applied to menu # beforeReposition: (offset) -> # offset.left += 10 # offset.top += 10 # offset beforeReposition: (offset) -> # After the `matcher` was failed, which it can't get any query string. afterMatchFailed: (at, el) ->
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论