javascript - Rails 3 - recognize attribute from textarea and grab it, if available -


i want build scratch , no request full code working solution, don't know start , need use , work on.

i have comment model, , i'm working on allowing users quote other users' comments. each comment has iteration_id, , users should write "#24", example, in comment-form textarea, quote comment #24. want app these kind of fragments "#[id]" in comment-form textarea , if available action them.

as said, don't expect give me code necessary function, i'm not sure how approach implementation of feature.
this, among others, regex function?

and related question, didn't want create own topic for: want users able click on comment's id shown "#16" link example, , "#16" should appear pre-written in comment-form, before user begins write comment. handle such thing javascript?

for first problem :

i use regexp catch string started # , followed numbers. can try regexp on rubular : http://rubular.com/

for example, regexp should work :

\s(#[1-9]+)\s 

(it takes part of text "space" + "#" + digit + "space"

for second problem, add string #16 textarea using javascript

in jquery :

$('textarea').val($('textarea').val()+' #16');  

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -