Giter VIP home page Giter VIP logo

Comments (2)

tarikhamilton avatar tarikhamilton commented on July 24, 2024 3

If I am understanding this correctly, #2 getInput(), getControl() also return jQuery elements, correct? If the are, the examples are a little inconsistent, which is what threw me off. If that is the case, I like idea #3 because you know they're jQuery and it seems more performant to only query when necessary, however you said performance is negligible.

But I also feel like I'm missing something. What is something like field.search = function(){}; supposed to return in #1?

When you say return a JS type instead of jQuery element, is there a JS object representing a field or do you mean returning an HTML${n}Element?

from acf.

elliotcondon avatar elliotcondon commented on July 24, 2024

Hi @tikitariki

Thanks for the reply and feedback. You raised some great points, and I'll address them below:

Point 1

If I am understanding this correctly, #2 getInput(), getControl() also return jQuery elements, correct?

Yes. I've just updated the examples to better reflect this.

Point 2

I like idea #3 because you know they're jQuery and it seems more performant to only query when necessary, however you said performance is negligible.

I'm leaning towards this idea too. It optimizes performance by only querying when needed, but also allows these functions to become dynamic and even allow for parameters.

Point 3

What is something like field.search = function(){}; supposed to return in #1?

This was an example to demonstrate how naming conventions are important. All functions that start with a $ symbolize those that return a jQuery element, nothing else.

Point 4

When you say return a JS type instead of jQuery element, is there a JS object representing a field or do you mean returning an HTML${n}Element?

Here I am talking about the differentiation between a jQuery object and any other JS type. The getX functions should return a JS type (string, int, object, array, etc) where as the findX functions should return a jQuery object.

from acf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.