So I created a little mixin to handle this, I'm not sure if it's the best
way to go about this, so I was hoping you guys could give me some advise on
this. I'm still utilizing the select event handler "change", but very green
to requireJs.

select-reload.js

define(["t5/core/ajax", "./jquery"], function(ajax, $) {
    return function(spec) {
        $("#" + spec.id).change(function() {
            ajax(spec.url, {
                type: "POST",
                dataType: "json",
                data: {
                    "t:selectvalue": $(this).val()
                },
                contentType: "application/x-www-form-urlencoded",
                success: function(response) {
                    return response;
                }
            });
        });
    };
});

SelectReload mixin

public class SelectReload {

    public static final String CHANGE_EVENT = "change";
    @InjectContainer
    private Field field;
    @Inject
    private ComponentResources resources;
    @Environmental
    private JavaScriptSupport jsSupport;

    void afterRender() {
        Link link = resources.createEventLink(CHANGE_EVENT);
        JSONObject spec = new JSONObject("id", field.getClientId(), "url",
link.toURI());

        jsSupport.require("select-reload").with(spec);
    }

}

page.java

    Object onValueChangedFromRowsPerPage(Integer rowsPerPage) {
        this.rowsPerPage = rowsPerPage;
        return this;
    }




On Sun, Oct 20, 2013 at 9:52 PM, George Christman
<gchrist...@cardaddy.com>wrote:

> Hello, I'm building my own PageRow component and I'm trying to figure out
> how to reload the page after changing the select value from say 10 results
> to 50. I need to set a query parameter during the refresh too, I thought I
> could do this using the onChanged event, but that does not work. Any one
> have any thoughts on how to do this?
>
> --
> George Christman
> www.CarDaddy.com
> P.O. Box 735
> Johnstown, New York
>
>


-- 
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York

Reply via email to