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

[eluser]xerobytez[/eluser]
What I usually do is set the success method for the jQuery forms library to eval the response it receives from the server. So the javascript would look something like this:

Code:
$(function() {
    $('#form').ajaxForm({
        success: function(response) {
            eval(response);
        }
    });
});

Then you can send any Javascript code you want from your controllers or where ever you are doing validation by doing something like this.

Code:
if ($this->form_validation->run() == true) {

} else {
    echo "$('#error_div').html('" . validation_errors() . "');";
}

If you do go this route you will have to extend CI's Form_Validation class. CI's form validation adds a "\n" or newline character after every error message. Javascript doesn't like that so extend form_validation->error_string and remove the "\n" from this piece below.

Code:
$str .= $prefix.$val.$suffix."\n";

Turns into:

Code:
$str .= $prefix.$val.$suffix;
#22

[eluser]Basketcasesoftware[/eluser]
Any chance we'll be able to see your working site in the near future, Timothy? Your last posting is the first time you've even used the word "product" and now I'm curious about what it could be. Might get yourself some good customers out of the CI forums Smile
#23

[eluser]Timothy_[/eluser]
[quote author="Basketcasesoftware" date="1298110963"]Any chance we'll be able to see your working site in the near future, Timothy? Your last posting is the first time you've even used the word "product" and now I'm curious about what it could be. Might get yourself some good customers out of the CI forums Smile[/quote]

Sure. Let me introduce it. Its facility scheduling, staff booking and project management software aimed at the Professional Film, Television and Radio industries.

What kind of projects are you working on?
#24

[eluser]Basketcasesoftware[/eluser]
My main project is a web-based game engine. It started out as a rewrite of the Improbable Island game code (http://ImprobableIsland.com) which is a hack of the Legend of the Green Dragon web game which is a rework of the Legend of the Red Dragon text game converted for the web. I'm having to develop the installer, the content editors, the module editors, the back end, some limited game mechanic enough that either of the games that inspired it can be imported into it, and so on.
My second project is an experimental re-write of a portion of the CI Loader class. I was in the middle of creating the formal fork for it when I saw your post. I had been using a text file in a thread until a member here asked me to go ahead and do a proper fork. Apparently I'm doing a good job.
My third project is to attempt to a framework to extend the CI framework to allow a database independent authorization and access control layers.
Plus I'm trying to get some free-lance web design and other IT work where I can.
I've been working off and on in the IT field for about 30 years.
#25

[eluser]Timothy_[/eluser]
Well done. The game looks quite interesting. Good luck with it all and thanks for your help.
#26

[eluser]Basketcasesoftware[/eluser]
Your site looks sharp indeed. I used to work for a small public access tv station part time (technically I'm still on the list of staff but I'm miles away now) and my mom used to work in radio advertising sales both as general staff and management.

I'm guessing you are working on the 1.5 upgrade right now.
#27

[eluser]Timothy_[/eluser]
[quote author="xerobytez" date="1298108006"]What I usually do is set the success method for the jQuery forms library to eval the response it receives from the server. So the javascript would look something like this:

Code:
$(function() {
    $('#form').ajaxForm({
        success: function(response) {
            eval(response);
        }
    });
});
[/quote]

Wow!!! Thank you so much for this. This is an amazing breakthrough and works almost perfectly.

One last brain teaser...

How can I snap the edit form out of just getting responses and take back control with codeigniter.

For example, when I try and do a redirect

Code:
redirect('home');

the page just sits there and does nothing.

I guess I want it both ways and I hope there is a way to achieve this.


[quote author="Basketcasesoftware" date="1298115694"]Your site looks sharp indeed. I used to work for a small public access tv station part time (technically I'm still on the list of staff but I'm miles away now) and my mom used to work in radio advertising sales both as general staff and management.

I'm guessing you are working on the 1.5 upgrade right now.[/quote]

Thanks for that. I am currently working on 1.3. Hopefully it will be finished soon!
#28

[eluser]Basketcasesoftware[/eluser]
Where are you putting that redirect function? In the view or in the controller? And are loading the helper library that includes it? And it might just be your path. Is your full path http://domain/root/index.php/home?

Sad. You killed your site link. I wanted to show that to my mom.
#29

[eluser]Timothy_[/eluser]
[quote author="Basketcasesoftware" date="1298195689"]Where are you putting that redirect function? In the view or in the controller? And are loading the helper library that includes it? And it might just be your path. Is your full path http://domain/root/index.php/home?

Sad. You killed your site link. I wanted to show that to my mom.[/quote]

Hello,

Yes the redirect is being called in the controller, something like this:

Code:
if($condition == TRUE) {
        redirect('home');
    } else {
        echo "$('.alert').html('Edit Successful');";
    }
The codeigniter user guide says:

Quote:You will not specify the full site URL, but rather simply the URI segments to the controller you want to direct to.

Before I implemented this ajax submit form the redirect was working.

Thanks,

Tim

PS. I can PM you the link if you want or you can just do a google search for it Wink
#30

[eluser]Basketcasesoftware[/eluser]
Actually I was thinking about Googling it. :cheese:

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? You've been having some strange results with your project as far as things not working like you'd expect.




Theme © iAndrew 2016 - Forum software by © MyBB