Pregunta

I'd like to use icons in an interface to trigger a select popup with X-editable, but I can't figure out how to replace the text content with an image.

Is there a way to do this with x-editable (for bootstrap) or do I need to create my own way of handling it?

¿Fue útil?

Solución

got it to work, leaving this up in case anyone is looking for this functionality or has a better way of doing it.

http://jsfiddle.net/UGWWA/11/

html:

<p>X-editable: single reqular checkbox</p>
<div style="margin: 150px">
    <img id="check" src="http://png-4.findicons.com/files/icons/2152/snowish/128/dialog_warning.png"/>
</div>

JS:

$('#check').editable({
    type: 'checklist',
    url: '/post',    
    pk: 1, 
    placement: 'right',
    title: 'Option 1',
    source: {'1': 'enabled'},
    emptytext: 'disabled',
    success: function(data, config) {
        if(data == '1'){
            $("#check").attr("src", "http://png-2.findicons.com/files/icons/808/on_stage/128/symbol_check.png");
        }else{
            $("#check").attr("src", "http://png-4.findicons.com/files/icons/2152/snowish/128/dialog_warning.png");
        }
    }
});

var a=0;
//ajax emulation. Type "err" to see error message
$.mockjax({
    url: '/post',
    responseTime: 400,
    response: function(settings) {
        if(settings.data.value == 'err') {
           this.status = 500;  
           this.responseText = 'Validation error!'; 
        } else if(settings.data.value[0] == '1') {
           this.responseText = '1'; 
        }else{
           this.responseText = '0'; 
        }
    }
}); 
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top