Can you use a "click" or "onclick" handler on SharePoint fields?

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
Jdubs
Posts: 73
Joined: Fri Dec 19, 2014

13 Jan 2015

When I add some code to perform an action for "onclick," nothing happens.


In my browser debugger, it says "Object doesn't support property or method 'click'


Is there a way to make this work?


I'm using --> fd.field('fieldname').click(function() {

//insert code here;

});

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

14 Jan 2015

Sure, please, try the code below:

Code: Select all

fd.field('fieldname').control()._el().find('input').click(function(){
	// your code here
});

Jdubs
Posts: 73
Joined: Fri Dec 19, 2014

14 Jan 2015

Thanks Dmitry! That works perfectly :)

Any idea why that works and fd.field('fieldname').click(function() doesn't work?

Only reason I ask is so that I can understand the Forms Designer framework a little better so that I don't have to bug you on questions like these in the future.


Thanks again!

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

15 Jan 2015

Hi,

fd.field('fieldname') returns Field object that doesn't contain click method. But you can retrieve jquery-object with the help of control()._el() method and find a particular html-element.

Bryan
Posts: 4
Joined: Mon Apr 27, 2015

26 Apr 2015

Hi, may i know what is the 'fieldname' and 'input' stand for?

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

27 Apr 2015

'fieldname' is an internal name of a SharePoint column.

'input' is an html-element that is rendered by the field.

Please, find more info in our documentation:
http://spform.com/documentation/js/field

And the blog:
http://spform.com/office-365/cond ... ynamically

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 28 guests