kof / field-selection

jQuery plugin for getting selection or replace a text in input field and textarea
MIT License
14 stars 5 forks source link

Again and Again Replaced Text #1

Closed varsadadj closed 11 years ago

varsadadj commented 11 years ago

Here Problem is that first time replaced but second time replace is not checked all ready text replaced by special character like that stackoverflow.com website comment box.

  1. Simple text select like that "text" and replace it with |* before and last _|
  2. result text with |_text*| and second time replaced text select text replaced original text "text"
  3. text
  4. 3.<> // wrong 4.text // right way E nex incontinencia, exigo era Palus sum iam magnificabiliter loci, sal incurro, dux necessarius Negotium os orbis, era alatus ineo, vel loquor, hic sed, Viva tam. Ico explorator mos, Expello hinc hac talio, mensa plures utor to tutamen eia Extundo sentus ita Novus, his Securus, tam nam Crepundia, Torreo fas Prolixus, nec flecto alibi peragro. Nam Deficio <> ops laeto aeger Freno .
kof commented 11 years ago

I am sorry, I don't understand .... can you make some code examples please, where is clear what you do and what you expect to get ...?

varsadadj commented 11 years ago

http://jsfiddle.net/varsadadj/KLevv/ Replace with special character like that bold text when remove bold tag remove. replace to selected text with $elem.fieldSelection('|'+selectedText+'|');

kof commented 11 years ago

why are you trying to replace the selection with jquery object? if you want to insert the text you have selected, then do this

    $('#replace').on('click', function() {
        $elem.fieldSelection('|*'+$elem.fieldSelection().text+'*|');
    });
varsadadj commented 11 years ago

Thanks for this a solution, but here problem that text insert with $('#replace').on('click', function() { $elem.fieldSelection('|'+$elem.fieldSelection().text+'|'); }); text replace with |text| but how to remove this text second time click on replace button not to replace again. e.g wmd editor

kof commented 11 years ago

you can't replace with this plugin text if its not selected ...