0

I have some gridster widgets.I want display on them the text content which will come from json(backend database,for simplicitiy I will be hardcoding it now).

The default function can generate the grids from a json variable.But I also want to display the text on those widgets as soon as the widgets are generated

My JS Code which gets variable from database and generates a grid from it

$(function() {
    gridster = $(".gridster ul").gridster({
        widget_base_dimensions: [100, 55],
        widget_margins: [5, 5]
    }).data('gridster');

    $('.js-seralize').on('click', function() {
        $.ajax({
            url:'127.0.0.1:8000/home',
            type:'GET', // This is the default though, you don't actually need to always mention it
        });

        var serialization = {
            {
                variable
            }
        };

        serialization_sorted = Gridster.sort_by_row_and_col_asc(serialization);
        gridster.remove_all_widgets();

        $.each(serialization_sorted, function() {
            gridster.add_widget('<li />', this.size_x, this.size_y, this.col, this.row);
        });
    });
}

My HTML

<div class="controls">
    <button class="js-seralize">Restore</button>
</div>

<div class="gridster">
<ul>
</ul>

The JSON which I get is of default form

[{"col":1,"row":1,"size_x":1,"size_y":1},{"col":2,"row":1,"size_x":1,"size_y":1},{"col":1,"row":2,"size_x":1,"size_y":1}]

I just want the text content on the grids somehow(by modifying JSON etc) or any way

NewBie
  • 3,124
  • 2
  • 11
  • 19
  • I am completely clueless about this.Any help will be really good – NewBie Mar 09 '18 at 11:28
  • You should set up what you currently have in CodePen or JsFiddle so we can get a better idea of what it is your have working and what you are trying to do. – ZombieCode May 31 '18 at 06:07

0 Answers0