Question

WE are currently in the midst of a migration from sharepoint 2007 to 2013.

I am experiencing a problem with the simple buttons on a webpart.

In a webpart ill insert a simple button:

<button id="button"><span>click me</span></button>

and in the jquery ill create a click event to take it to a page.

$( "#button" ).button().click( function (event) {
        window.location = "/SitePages/testPage.aspx";
    });

In 2007, the user clicks the button and it takes them to the desired page, however, in sharepoint 2013, when i hover over the button, i can see it points to the current page, and the user is only taken to the desired page if they click the button twice in quick succession.

Does anyone have a solution to this as to what could be causing it?

a bit of extra info is that we seem to be having issues with jquery on sharepoint 2013, we are using jquery 1.9.1. we get the following error when a user clicks anywhere on the page (so far unresolved):

SCRIPT5007: Unable to get value of the property 'call': object is null or undefined 
jquery.validate.min.js, line 50 character 199

This worked fine on 2007. the version of jquery validate we have is 1.9.

Browser: ie9 browser mode: ie9 compat view document mode: ie9 standards

Any help at all would be greatly appreciated

Was it helpful?

Solution

Try using

$( "#button span" ).click(function(){
    window.location = "/SitePages/testPage.aspx";
});

OTHER TIPS

I think MageQue's answer will address your issue with the button clicks.

To address your jQuery error issue, it's quite possible another SharePoint JS library is redefining the $ alias. Try replacing references to $ in your custom script with jQuery.

For example, if you're using the ready function, change from:

$(document).ready( function() {

 // code here
});

to

jQuery(document).ready( function() {

  // code here
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top