I am using a custom-created button on my HERE Map using the JS 3.0 library.
I followed a HERE support engineer's suggestion provided here: HERE Map UI JS - How to add custom buttons to the Map UI?
So far, I have been able to get it to work just fine, but I just found out that I need to be able to enable or disable the button depending on various business rules. But it looks like there is no "setDisabled" functionality for HERE Controls or Buttons?
https://developer.here.com/documentation/maps/api_reference/H.ui.Control.html
https://developer.here.com/documentation/maps/api_reference/H.ui.base.Button.html#.State (I saw that there was the option to initialize a button to be disabled, but not to change an existing one. Seems inefficient to create a new button every time I need to enable or disable it.)
Any suggestions?
Dont use the var ui = H.ui.UI.createDefault(map, maptypes, 'en-US'); line in order to disable buttons or find your self in an "if" statment to access this when a certain button is pressed or statement is passe
There is a setDisabled() method inherited from the parent class H.ui.base.Element which you can use:
// assume custom UI control exists
customControl.setDisabled(true) // <- disables the control
customControl.setDisabled(false) // <- enables the control
Here is jsfiddle working example of custom UI control which disables itself after click.
See H.ui.Control#setDisabled() for more details.
Related
i'm new with Odoo 8. I added a Button in my module (inherit sale order) to be able to execute the method calkulateEKNew. The function is calling how it should be, but it looks like that the button is doing more stuff in the background. After clicking the button it saves the sale order and calls the method calkulateEKNew.
Is it possible to trigger this button or to find the logic behind the button ?
Nice regards
Buttons are available to execute python methods on the Odoo server.
If you want to execute JavaScript code, you'll have to add a (client-side) widget, possibly a template and a JavaScript file to your module.
This URL points to further information about simple widgets:
https://www.odoo.com/documentation/8.0/howtos/web.html#widgets-basics
I am new to CC Guidewire. I didnt understand what post on change will do?
Thanks.
The "postOnChange" attribute on a PCF UI element can either be true or false.
If it is true then everytime that UI field is changed by a user; it will POST back to the server.
The server will then execute the code in corresponding UI elements "onChange" attribute.
These together basically allows you to add a piece of code that will fire when that UI field is been changed on screen by the user.
The reflection items can be used to use AJAX style updates to multiple fields on the basis of others. It is a bit more complex to use and understand.
I'm trying to use the Buttonset widget in JQuery UI. I've got the package loaded and my template renders the radio buttons fine. I have a "rendered" function to call the JQ UI routine to setup the buttonset:
Template.teamList.rendered = function () {
$("#buttonsetID").buttonset();
}
But it looks like the rendered function is being called before the template is rendered! I stick a console.log in the function and it prints out to the console before there's anything on the screen. So none of the radio buttons are set up, therefore the .buttonset() call does nothing. If I make that call in the console after the page is rendered, JQuery UI does the right thing and my button set appears.
Isn't the .rendered function supposed to be called after everything's set up? Am I doing something wrong?
Thanks!
edit:
As an example, the same thing is seen in the leaderboard example.
If you add:
Template.leaderboard.rendered = function() {
alert($('.player').length);
}
When the page is displayed, it will show 0. This makes it difficult to access the DOM items if you need to add some JQuery events or, in this case, a JQuery UI element.
rendered only works for elements which will appear in the DOM the very first time the template is added to the page. Assume that subscription data takes infinitely long to arrive, then look at the template and see which elements would appear in the default state.
Using the leaderboard example, we can't assume that players are available when the leaderboard template renders (it depends on a subscription). To target a player, you should use the rendered callback on the player template.
It's hard to generalize a strategy for when to apply jQuery plugins, but here are some ideas:
Use the rendered callback if the element will always be added in the default state (e.g. the element is hard-coded and doesn't depend on a conditional).
Use the rendered callback of the most specific child template to target that child (e.g. the player template from above).
Consider using an event handler callback to target the element if it's appearance depends on an event (e.g. a button click).
Consider using a template autorun callback to target the element if it's appearance depends on reactive state. See this question for an example.
I have an MVC 2 project, consisting of a MasterPageView a child View called Index and a number of PartialViews. The PartialViews are loaded into the Index View using the jQuery Ajax method $.get(....).
My problem is that I am styling the buttons using jQuery UI like:
$('button').button();
but I find that I need to do this on every PartialView. What I would like to do is define
this once in the MasterPageView, but if I do this the styling is lost. I'm guessing this
is because the styling is applied before the DOM is loaded, is this correct? Is there any
way to implement this i.e. just define it on the MasterPageView?
Thanks for the help !
This wont work when objects are added to the DOM after the initial load. In those cases you should go for the new .live() syntax in jQuery :
$("button").live("load", function(){
$(this).button();
});
It listens for new objects being added to the DOM and attaches an eventhandler to it..
Hope that helps!
I have a button on a webpage that has the following added programmatically to its “Attributes” property.
btnDeleteNode.Attributes.Add("onclick", "if(confirm('delete this node?')){}else{return false}");
This works fine but now I need to check to see if the user has selected a node in a tree before asking if they want to delete it. If a node isn’t selected I need to tell the user to select one. My question is, can I do this using the above method (I don’t know java script) or should I use a different approach ?
You can set a flag (using javascript) on selection of any node and check the flag here.
You can use a flag or use from Asp Validators