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

rss

Posted by Jdubs - Jan 13 ’15 at 10:47

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;

});

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 10 months 26 days
    #1 by Dmitry Kozlov Jan 14 ’15 at 06:30

    Sure, please, try the code below:

    fd.field('fieldname').control()._el().find('input').click(function(){
    	// your code here
    });
    
  • Jdubs
    Member
    Member for: 4 years 7 months 28 days
    #2 by Jdubs Jan 14 ’15 at 04:09

    [#1]: Thanks Dmitry!  That works perfectly smile

    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!

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 10 months 26 days
    #3 by Dmitry Kozlov Jan 15 ’15 at 03:54

    [#2]: 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
    Member
    Member for: 4 years 3 months 25 days
    #4 by Bryan Apr 26 ’15 at 09:05

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

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 10 months 26 days
    #5 by Dmitry Kozlov Apr 27 ’15 at 09:44

    [#4]: '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://formsdesigner.blogspot.com/2014/07/how-to-conditionally-hide-disable-make.html

Displaying 1 to 5 of 5 messages