I'm trying to edit this js code so that the autocomplete function kicks in after each non-breaking space; regardless of whether or not the text entered before each non-breaking space was one of the tags. So, for example, if I enter PHP, that's one of the tags. But, if for the next text that I enter, it must be one of the tags too otherwise anything that I enter after PHP will not activate the autocomplete. You can find this example on jsfiddle
I think that you're looking for a plugin like this one:
http://levycarneiro.com/projects/tag-it/example.html
- or -
http://code.drewwilson.com/entry/autosuggest-jquery-plugin
Basically you need to look for "jQuery Autocomplete Tags" instead of just "jQuery Autocomplete".
Related
I have a requirement where if user enters anything in the free text field, it should be written on Page, problem i am facing when user enters any html character, it doesnt write anything, as it takes it as html character instead of normal text.
http://jsfiddle.net/mJwwS/
$('#add').on('click',function(){
$('#hey').html($('#oye').val());
});
Use .text() method instead:
$('#hey').text($('#oye').val());
DEMO: http://jsfiddle.net/mJwwS/1/
How do I prevent input in texts fields from containing HTML and JavaScript code?
Example: I have an input text field. If the user enters javascript instructions, then they get executed.
How can I modify
<script>alert('aces')</script>
so that it will show up as normal text in my field and not as a alert when i try to list it?
Have you looked into libraries like underscore.js (used by Backbone.js)?
It comes with escape functions that prevents user entered javascript to run.
http://underscorejs.org/#escape and http://underscorejs.org/#unescape
so you would write:
alert(_.escape(USERINPUT));
this becomes even more important when you add user input to your DOM, for security reasons you need to escape inputs (or allow only a selection of harmless tags like < strong >).
I'm using OpenMRS, it's an opensource medical records system. OpenMRS has a built-in html editor and I use this mostly in javascripting ang building the forms. In one of my forms,I have a textarea. My client would like his entries(in paragraph or in list) to be indented in the textarea.
Now when you try indenting the paragraph in the textarea then save the changes and preview the form, the paragraph becomes justified instead of retaining the indented lines.
However, if I try indenting the paragraph using ascii code for non-break space by typing or pressing alt-288, the paragraph becomes indented thus giving me the desired result. Now, the users don't prefer typing or pressing ascii equivalents coz that'll be hassle on their part.
I'm using mostly javascript and jQuery because it's what openmrs supports. If I could somehow bind the non-break space character upon pressing a key then this will work, but I'm at a lost here. How will I do this in javascript or jquery?
One solution which might work for you is to replace leading spaces in the textarea when you process/save or even each time it changes it something like :
ta.value = ta.value.replace (/\n +/, function (m) {
return '\n' + Array (m.length).join (' ');
});
The Array ... constructs creates an array containing length elements then joins with your non-breakspace character effectively creating a string of that many space chars.
Another possibility is to watch for space characters entering the text-area and transforming them. See here : Can I conditionally change the character entered into an input on keypress?
Is there a keystroke to add double quotes around a selection in xcode?
I have snippets #"<#string#>" (qt) and #"<#string#>"<#, #> (qtc)(for making a list in array I use keystroke qtc+enter word tab enter qt+enter...) that I use when I am typing, but I also could use some sort of a macro that I could highlight the word, tap a keystroke, and it would add #"" around it. It seems a little easier. Once you enter the first qtc then you just need qt enter to get the next one from the code popup.
Is there a macro that would put the quotes around the current word the cursor is on? I have seen something like this in TextMate.
This would be a little convenience that would be nice when I am adding a list of words to an array or something and putting the quotes around all the words.
Maybe a little javascript to put in a webpage that would loop though and put the quotes each word in a list would be useful. Or better yet an applescript or some sort of macro that could be used in xcode that would loop through words in a selection and add #"", around each word that could be triggered with a keystroke. Then you could just type a list and select it and tap a keystroke and you just saved a ton of typing.
I found this applescript that replaces text webpage:
http://foolsworkshop.com/applescript/2008/05/an-applescript-replace-text-method/
If you use that you can use applescript with a list separated by commas copied to the clipboad:
set theText to the clipboard
set theReplacedText to replaceText(", ", "\", #\"", theText)
return theReplacedText
then copy the results to the clipboard and paste them where you want. I'm not sure how to get it to activate with a keystroke and replace the selected text a little more neatly.
Is it not the same as in other languages like so NSString *string = #"Some text here /"Here is the text/" ";
I have some text in a textbox. I automatically select some of it by calling textbox.setSelectionRange(a, b). But then, when I start typing again, the letters are appended on the right of the selection instead of replacing the selected text. Is there any way I can make the selection 'replaceable' by the user?
edit: it seems that if you execute the function twice on the same piece of text, the text doesn't replace any more. So that's what happened