Getting started with $().SPServices.SPRedirectWithID

Dec 7, 2009 at 10:23 PM

Hi,

  I am having trouble getting this to work.  I am trying this in my root site with a simple task list.http://mysite.com/Lists/Tasks/

 I have made a custom newform called Lists/Tasks/NewForm_copy1.aspx I have added the following lines from the instructions underneath <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">

I have created my jquery library and loaded the two files in my src statment below.

<script type="text/javascript" language="javascript" src="/jQuery%20Libraries/jquery-1.3.2.min.js"></script>
<script type="text/javascript" language="javascript" src="/jQuery%20Libraries/jquery.SPServices-0.4.5.min.js"></script><script language="javascript" type="text/javascript">
      $(document).ready(function() {
            $().SPServices.SPRedirectWithID({
                 redirectUrl: "EditForm.aspx"
            });
      });
</script>

I also have edited my supporting file to point to the newform_copy1.aspx page    My page does not redirect. It looks like it is attempting to redirect because there is a pause but it stays on the newform_copy1.aspx. 

I then dropped this code in to make sure my source calls were correct.

<script type="text/javascript" language="javascript" src="/jQuery%20Libraries/jquery-1.3.2.min.js"></script>
<script type="text/javascript" language="javascript" src="/jQuery%20Libraries/jquery.SPServices-0.4.5.min.js"></script>
 <script type="text/javascript">
       $(document).ready(function() {
          alert("Hello jkdevela!");  
       });
</script>

I do see the “Hello jkdevela!”  message.

I tried hard coding the redirect link and that did not work. Can I add some sort of debug functionality? Is there something obvious I am missing? i am out of ideas.

I am looking forward to getting this working - thank you for shareing this code.  -

Peter

Coordinator
Dec 8, 2009 at 2:32 AM
Edited Dec 8, 2009 at 3:24 AM

Peter:

From what you've posted, all seems correct.  Is the item being saved?  Do you see any JavaScript errors at all?

I see that you are using v0.4.5. I don't believe that I made any changes to SPRedirectWithID, but could you try upgrading to v0.4.6?  In any case, there are some other efficiencies in v0.4.6 so I would recommend that you use it going forward, anyway.

M.

Dec 8, 2009 at 2:58 PM

Hi,

 Its working this morning. I think it was my errror after all. I tried it in another site and it works fine. I went back to my first site and realized I did not have the changes in the right test page.. Human error.  I am sorry for the post.

Very nice code.

Thank you.

Coordinator
Dec 8, 2009 at 3:01 PM

No problem at all.  If we eliminated human error, we wouldn't be human anymore.  Let me know how it goes and what turns out to be most useful for you.  I also take requests.  I want this library to be built based on real user need, so I'm always listening.

M.