Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serialize_params Returns Odd Info #595

Open
JayRennemeyer opened this issue Sep 12, 2017 · 0 comments
Open

serialize_params Returns Odd Info #595

JayRennemeyer opened this issue Sep 12, 2017 · 0 comments

Comments

@JayRennemeyer
Copy link

I'm trying to get the ID of a widget container when it gets resized. I added an .attr call to the serialize_params function and it worked for a while. It returned [{"element_id":"admin_stats","col":7,"row":3,"size_x":6,"size_y":4}]. But now it's sending weird data back to the resize.stop function.

Gridster Code:

        var gridster = $('.gridster > .widgetContainer').gridster({
            widget_margins: [10, 10],
            widget_base_dimensions: [100, 60],
            min_cols: 12,
            max_cols: 12,
            resize: {
                enabled: true,
                stop: function(e, ui, $widget) {
                    var widgetInfo = JSON.parse($widget);  // <---Throws error shown below.
                    var newHeight = this.resize_coords.data.height;
                    var newWidth = this.resize_coords.data.width; 
                    $('li#' + widgetInfo.element_id).attr('backgriound-color','red');
                }
            },
            serialize_params: function($w, wgd) {
                return {
                  element_id: $w.attr('id'),
                  col: wgd.col,
                  row: wgd.row,
                  size_x: wgd.size_x,
                  size_y: wgd.size_y,
                };
            }
        }).data('gridster');

The error shown in the console is:
Uncaught SyntaxError: Unexpected token o in JSON at position 1

If I display the results of JSON.stringify($widget), it contains:
{"0":{"jQuery11240030910348659392684":192,"sizzle1505230551480":{"undefined":{"parentNode":[19,14,true]}}},"length":1,"prevObject":{"0":{},"context":{},"length":1},"context":{}}

What is happening and how do I fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant