Master, Detail, Ajax And Script

Hello again.

Today I have a "large to explain" problem:

I have two models, Master,and Details, each Invoide can have many details:

I have a form like the following:

As yo can see, I make an ajax call to master/addDetail, here is the code:

Now, the view /detail/_table is the following:

This works perfect, I mean, I fill the "Detail section" of the form and when I click on "Add detail" a new Table, is appended to the listDetails div.

That table has the names of the field, id, and values filled correclty too.

But, the script that should work (e.g. The datepicker, or the script for the remove button) doesn't work.

I like if these scripts never exists.

I hope that this be clear, and that anybody can help me with that…

Hi,

well, in my opinion it's true - they really don't exist…

Because you're making an ajax call and the renderPartial sends the contents of /detail/_table back, but you're not reloding the page, so how should yii be able to insert the JS code inside the document.ready function?

This would mean that yii has to extend the document.ready function dynamically (also with javascript) or you think, that you can have two of these functions, just because you are using a view?! This doesn't work.

For the delete button it's quite simple to solve, you can add the function directly to the button, there is no need to put it inside the ready-function. To be absolutly sure that the page is completly loaded at this point you may enable the 'Add details'-button via js inside the ready function.

With the DatePicker i think it's a bit tricky if you want to use the extension instead of creating your "own" one directly using jQuery.

Greets

Hi,

In the above post of yours, your code samples cannot be seen. I want to make a detail entry form and want to make something similar to yours. Would you mind posting the code samples for your form, the ajax call to master/addDetail and the view /detail/_table.

Many thanks,

Bilge

Really I want ti understand Master-Detail with Yii , But until now I could not found documentation about it.

Please help us …

Thanks,

The code dissapears because, when the site was very young, another forum engine was used (PhpBB if I’m not wrong).

Later the forum was upgraded to IP.Board and in the import of the old forum conversations some thiws were lost (code, some links, images, etc).

But, to answer your question, I haven’t that code right now, but I can give you something:

http://www.yiiframework.com/wiki/29/how-to-create-save-more-model-inputs-and-make-them-repeatable-with-jquery/

What I try to do is something like that, you can see there for some inspiration!!!