Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

x-editable, how to show specific value when string is empty?

I am trying to show a default value when a field is null or empty (string), and edit mode is disabled using x-editable. Using the attribute "data-value" works great when the field or string is null, for example:

<b><a id="location_name" data-type="text" data-title="Location name" data-placeholder="Location" data-emptytext="Location" data-value="Location">@Model.geoLocation.location_name</a></b> <br />

However, if the string is empty (but not null), the data-value will not show. I was wondering if there is a way to still show the default data-value if the string is empty (i.e., in addition to when it is null).

like image 614
gnychis Avatar asked Dec 06 '13 01:12

gnychis


1 Answers

This works for me:

<script type="text/javascript">
  $(document).ready(function() {
    $.fn.editable.defaults.mode = 'popup';     

    $('.confirm_assistance').editable({
        url: '<?php echo PATH; ?>controllers/administrator/insert/boardingListPax.php',
        emptytext: 'Text for empty/null value'
    });
});
</script>

The thing here is to use

        emptytext: 'Text for empty/null value'
like image 133
Juan Del Árbol Avatar answered Nov 15 '22 13:11

Juan Del Árbol