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: 9 years 8 months 16 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: 8 years 5 months 19 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: 9 years 8 months 16 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: 8 years 1 month 14 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: 9 years 8 months 16 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

  • peter0900
    Member
    Member for: 6 months 29 days
    #6 by peter0900 Apr 11 ’23 at 12:10

    When a button is clicked, the on-click event causes a specific functionality to be carried out. This might occur when a user submits a form when you modify certain web page content and other similar events.

    Home Improvement Contractors Near Me

Displaying 1 to 6 of 6 messages