Forum

July 10th, 2011
You must be logged in to post Login Register

Search Forums:


 






jquery alpha 3 and postdata with create action

UserPost

08:03
13/05/2009


glennswest

Member

posts 8

Howdy

Making good progress on my plugin for rails and jqgrid, I'm adding

support for the authenticity token. I'm attempting to use postData

to set the value to be passed back. I see it passed on all requests except

create. (Which of course is where I need it the most).

So what am I doing wrong here. Is there another option to the grid for the create action?

The jqgrid:

http://www.pastie.org/476753

13:10
13/05/2009


tony

Sofia, Bulgaria

Moderator

posts 7010

Hello,

I do not think that this is a bug. Actually we separate the data that is posted for editing, deleting and adding from those that is needed to load the data in the grid.

You do not do anything wrong. You need to use the events in adding record and extend the postData array with what you posted to the server.

Also some hint – you can use beforeSubmit event something like

beforeSubmit : function (mypostdata, formid) {

// get the postData array using getGridParam

// extend the postData with mypostdata array

// use setGridParam to update the postData

return [true,"",""];

}

00:17
14/05/2009


glennswest

Member

posts 8

Cannot for the life of me, get the beforeSubmit to run.


http://www.pastie.org/477666


Code looks right, least I should get a breakpoint on entry to the function in firebug, but nothing. It never gets called. I'm using the inline edit, just wondering if that is driving it crazy. 

03:27
14/05/2009


glennswest

Member

posts 8

Ok, I'll answer my own question. :)


The key to having this work is in the editRow, when you are doing the inline editing. As it does the save, and does not trigger other events. 

I also found out that least in my Ruby 1.9.1 with Rails 2.3.2 the Javascript encodeURIComponent is redundant, and will cause the authenticitytoken not to work. (Despite plenty of examples that use it, possibly in older rails). 


I can now do edits just fine with authenticyToken working as intended. 

The final code:

http://www.pastie.org/477749

Here is the wrong way, with the encodeURIComponent:

Processing AirstateController#index to xml (for ::1 at 2009-05-14 16:09:31) [GET]

  Parameters: {"nd"=>"1242288570914″, "_search"=>"false", "rows"=>"10″, "page"=>"1″, "sidx"=>"id", "sord"=>"desc", "controlle"*********HERE******** "

"GoSD7xNPpttz2h2VjDyi28rt6pXPao7KsMdnzPGBr3I="

"GoSD7xNPpttz2h2VjDyi28rt6pXPao7KsMdnzPGBr3I%3D"

Notice the "=" has been encoded in the one we are returning, but not
the one we are comparing it too.
After we remove the encodeURIComponent, the comparison is good:
"*********HERE******** "
"GoSD7xNPpttz2h2VjDyi28rt6pXPao7KsMdnzPGBr3I="
"GoSD7xNPpttz2h2VjDyi28rt6pXPao7KsMdnzPGBr3I="
Thanks for the help. Now on to the next issue. :)

05:54
14/05/2009


glennswest

Member

posts 8

Ok, I spoke to soon, (After I pushed to github too).

The delete request (And I assume the add as well) need the

extra parameters. I tried postData, but doent seem the right place.

Is there a event, or is there a parameter?


Processing AirstateController#create (for ::1 at 2009-05-14 18:45:37) [POST]

  Parameters: {"oper"=>"del", "id"=>"1564″, "controller"=>"airstate", "action"=>"create"}

21:51
14/05/2009


glennswest

Member

posts 8

Ok, resolved. I've moved to stuffing the token in the editurl.

That solves it for add/update/delete. Looks like delData

cannot be set in the grid definition, which I would have expected

to work. From reading the code, only can be passed on the function call.


I've updated the plugin, and pushed it to github if anyone wants to see.


Thanks for the support. 


Oh by the way, is there a update for the forum, the captcha has a wonderful way of losing my posts, third time to type this one.


About the jQuery Grid Plugin – jqGrid forum

Most Users Ever Online:

157


Currently Online:

37 Guests

Forum Stats:

Groups: 1

Forums: 7

Topics: 9596

Posts: 28792

Membership:

There are 10195 Members

There have been 448 Guests

There is 1 Admin

There are 2 Moderators

Top Posters:

OlegK – 1157

markw65 – 179

kobruleht – 144

phicarre – 126

YamilBracho – 124

Renso – 118

Administrators: admin (56 Posts)

Moderators: tony (7010 Posts), Rumen[Trirand] (81 Posts)




Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information