NetTalk Central

Author Topic: Customize Save and other standard buttons  (Read 3306 times)

Djordje Radovanovic

  • Full Member
  • ***
  • Posts: 237
    • View Profile
Customize Save and other standard buttons
« on: December 30, 2014, 03:53:00 PM »
I need to customize buttons with javascript code. JS code looks like this

$(function () {
$("#save_btn").ejButton({
ShowRoundedCorner: true,
size: "mini",
type: "submit"
});
});

where #save_btn is button id. It would be nice for me to know what is the name of id in NetTalk form but save_btn has random sufix and every instance of page has different button id. How to overcome this problem?

Best reagards,
Djole

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Customize Save and other standard buttons
« Reply #1 on: December 31, 2014, 12:00:18 AM »
Hi Djole,

In HTML the ID has to be unique, and you can have multiple save buttons on a form, so they all have to have a unique id.
Fortunately there are other selectors you can use;

So, as you know, the # means "match id". As in
$("#save_btn")
this will match to the item with id="save_btn"

You can also match on "function". All save buttons have an attribute
data-do="save"
The selector for this is
$("[data-do=save]")

Use this if you want your code to apply to _all_ the save buttons on the form.

Another approach is to add a CSS class to the button - you don't have to actually create a class, just assign a class to the button. Then only the specific buttons with your assigned class will be selected when you use a selector like this;

$(".someclass")

remember css is case sensitive though...

Selectors are an enormously powerful tool when it comes to writing JavaScript - you can read up on them on the jQuery site if you like.

Cheers
Bruce

Djordje Radovanovic

  • Full Member
  • ***
  • Posts: 237
    • View Profile
Re: Customize Save and other standard buttons
« Reply #2 on: January 02, 2015, 01:13:15 AM »
Thank you Bruce and happy New Year.

Best regards,

Djole