EasyUI Forum
March 28, 2024, 07:07:05 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: texteditor promp  (Read 4584 times)
catpaw
Jr. Member
**
Posts: 85


View Profile Email
« on: February 21, 2017, 01:31:39 PM »

hello I'm trying to capture the event focus and blur for texteditor but not good so far

what I want is make promp function for texteditor

Code:
$(function() {
var default_promp = "Texto detallado de su solicitud...";
$('#te').on('blur', function () {
var promp = $.trim($('#te').texteditor('getValue'));
if(promp == ''){
$('#te').texteditor('setValue',default_promp);
}
}).on('focus', function () {
var promp = $.trim($('#te').texteditor('getValue'));
if(promp == default_promp){
$('#te').texteditor('setValue','');
}
});
});
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #1 on: February 21, 2017, 07:14:15 PM »

The texteditor has no 'prompt' or 'placeholder' properties. A possible solution to add the prompt feature is to add a special background image instead of the prompt text. Please look at the code below:
Code:
<style>
.nocontent{
background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' version='1.1' height='50px' width='120px'><text x='0' y='15' fill='red' font-size='20'>Texto detallado de su solicitud...</text></svg>");
background-repeat: no-repeat;

}
</style>
<script type="text/javascript">
$(function(){
$('#te').on('keyup',function(e){
if ($(this).text()){
$(this).removeClass('nocontent');
} else {
$(this).addClass('nocontent');
}
})
})
</script>
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!