Welcome Guest, Not a member yet? Register   Sign In
Repopulating Form being displayed through Jquery UI tabs interface
#31

[eluser]Timothy_[/eluser]
[quote author="Basketcasesoftware" date="1298197566"]Odd side effect of the Ajax I guess. I know the manual suggests otherwise, but try it with a full url. Or have you done that already?[/quote]

Yeah I have tried it anyway and no luck. I suppose it does make sense in a way. The ajax is just passing that on as a response... but then again surely a controller should be able to override that. I have also tried the refresh attribute without luck.

Code:
redirect('home', 'refresh');

[quote author="Basketcasesoftware" date="1298197566"]You've been having some strange results with your project as far as things not working like you'd expect.[/quote]

I see it as part of the learning process and I've grown used to things not working as expected... adds to the excitement of developing Smile
#32

[eluser]Basketcasesoftware[/eluser]
How about passing it on to a different controller and see if that works. I know that isn't the final objective but it's a way to exclude an issue. If it works just create a controller like (I'm trying to adjust for 1.7):
Code:
class Redirector extends Controller
{
function Redirector()
{
  parent::Controller();
}

function index()
{
  $this->load->helper('url'); // I think this is the right load for the redirect helper.
  redirect('home');
}
}

Just a shot in the dark right now.
#33

[eluser]Timothy_[/eluser]
Yeah the redirect works in any other controller, just not in the one where it is also outputting ajax.
#34

[eluser]Basketcasesoftware[/eluser]
And that one denies redirection to any other controller... at least that's what I'm gathering from your reply.
There is this comment at the end of the 2.0 Guide for the redirect method.
Quote:Note: In order for this function to work it must be used before anything is outputted to the browser since it utilizes server headers.
Note: For very fine grained control over headers, you should use the Output Library's set_header() function.
I'm looking at the set_header function now.
#35

[eluser]Basketcasesoftware[/eluser]
How about getting the output at the end of that controller method using $this->output->get_output() and writing it to a file somewhere? That might help you with diagnostics here.
#36

[eluser]Timothy_[/eluser]
Hmmm I was doing some research and I think I am going to have to put a condition in my jquery form.

I found this code from this post http://stackoverflow.com/questions/19909...-ajax-call

Code:
$.ajax({
    type: "POST",
    url: reqUrl,
    data: reqBody,
    dataType: "json",
    success: function(data, textStatus) {
        if (data.redirect) {
            // data.redirect contains the string URL to redirect to
            [removed].href = data.redirect;
        }
        else {
            // data.form contains the HTML for the replacement form
            $("#myform").replaceWith(data.form);
        }
    }
});

Now I just have to work out how to integrate it into my code.
#37

[eluser]Basketcasesoftware[/eluser]
Looks you just need to be able to assign data.redirect. I wonder if you need the full URI, or just the usual CI partial? I'm still curious why it's disabling normal CI output behavior.
#38

[eluser]xerobytez[/eluser]
Try this out Timothy

Code:
if($condition == TRUE) {
    echo "*.location = '" . site_url('home') . "';";
} else {
    echo "$('.alert').html('Edit Successful');";
}

lol, the forum is filtering my code out of fear for xss, so * = window
#39

[eluser]Timothy_[/eluser]
Hey xerobytez,

It works perfectly. Thank you so much for putting the time into this.

I have another issue that you may see a solution to (if you have time that is).

I have a WYSIWYG editor in the form and I need to append its output to its textarea manually. This is what the updateText function is for. I am using the ajaxForm "beforeSubmit" callback.

Code:
//For Ajax Form
$('#addFaci').ajaxForm({
        beforeSubmit: updateText,
        success: function(response) {
            eval(response);
        }
});

function updateText(formData, jqForm, options){
    var save = '#detail';
    $(save).val($(save).htmlarea("toHtmlString"));
    return true;
};

This is working in Chrome but not firefox... In firefox you have to click submit twice before this actually updates. Do you have any ideas?

Thanks,

Tim
#40

[eluser]Basketcasesoftware[/eluser]
I've seen this with FireFox as well lately. And not just with forms, but with links and other general features. It's been rather annoying. I guess it's a "feature" of FireFox right now. Sad At least this was the case with FireFox < 4.0 FireFox 4.0 Beta 11 doesn't seem to have this problem (in fact I'm using it right now).




Theme © iAndrew 2016 - Forum software by © MyBB