Welcome Guest, Not a member yet? Register   Sign In
Jqgrid and refreshing page
#4

[eluser]jwindhorst[/eluser]
Right, let me see if I can explain my thought a little better.

Let your page load (initial load) without your text boxes. Then send a "lazyload" Ajax request out to a controller called Ajax_controller. Inside that controller, make the calls to your model to get and manipulate your data. Pass that data back to your Ajax_controller, and use that controller pull in your "text_fields.php view". You can call it whatever you want, but it's a view that does nothing but display those three text boxes with their proper/current values.

If you run this when the page is first loaded it might look something like:
Code:
[removed]
$(document).ready(function(){
    $.post('Ajax_controller/get_text_fields', function(data) {
        $('#text_fields_wrapper').html(data);
    });
});
[removed]

What that does is say, ok, our page is loaded, now I'm going to grab the HTML to create the text boxes, and I'm going to dump it into my html div element that has an id of text_fields_wrapper.

You could alter that script just slightly to make it work against any javascript event. For example, the user changes a value and clicks the 'Send Values' button:
Code:
[removed]
$(document).ready(function(){
    $('#send_values').click(function(){

        $.post('Ajax_controller/get_text_fields', function(data) {
            $('#text_fields_wrapper').html(data);
        });

    });

});
[removed]

The only difference here is that you are not re loading that element until you click the button. Depending on how it needs to work for the user, you could bind to the change event or anything else also.

This sends an ajax request to your Ajax_controller. Inside there you can do any of the processing you normally would; call a model, manipulate your data, whatever you need to do. Once you load that view at the end of the controller call, the request will come back to the browser and repopulate the HTML inside of your #text_field_wrapper div, which will naturally be the same HTML as before, with new values.


Messages In This Thread
Jqgrid and refreshing page - by El Forum - 03-21-2012, 04:10 PM
Jqgrid and refreshing page - by El Forum - 03-21-2012, 09:51 PM
Jqgrid and refreshing page - by El Forum - 03-22-2012, 09:52 AM
Jqgrid and refreshing page - by El Forum - 03-22-2012, 11:10 AM
Jqgrid and refreshing page - by El Forum - 03-23-2012, 12:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB