Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > HTMLfield onClick not working

Forum

Search UsersRules
HTMLfield onClick not working
#1
Just came
Points:: 0
Joined:: Sep 12, 2016

Hello,

Can someone provide me a simple configuration or code fragment with a html script that can trigger the onClick event on HTML fields?
I tried and I managed to trigger this event only with an link, but I need to trigger it when I click on a button.

Can anyone help me please?

Thank you!

Profile
#2
Guest
Points::
Joined::

Hello, Sebi Dan!

You can find some examples in 1C:Translator. The Texts catalog has TranslationInterface template where the interaction with JavaScript implemented.

Telling short, you can fire an onclick event and pass some parameters in the document properties.

Code
  window.document.LastEventType = "clickbutton";
  window.document.LastEventData = <your data>;
  fireEvent(window, eventType);

fireEvent(window, eventType)
{
  if (window.document.createEventObject)
   {
      // IE
      var newEvent = window.document.createEventObject();
      return window.document.fireEvent('on'+eventType, newEvent);
  }
  else
   {
      // others
      var newEvent = window.document.createEvent('HTMLEvents');
      newEvent.initEvent(eventType, true, true ); 
      return !window.document.dispatchEvent(newEvent);
  }
}

On the 1C:Enterprise side:
Code
Procedure EditorOnClick(Item, EventData, StandardProcessing)
   If ValueIsFilled(Items.Editor.Document.LastEventType) 
         And Items.Editor.Document.LastEventType = "clickbutton") Then
      ...
   EndIf;
EndProcedure

Profile
#3
Guest
Points::
Joined::

The other option is using CSS to change style of the link to look like a button.

Profile
#4
Just came
Points:: 0
Joined:: Sep 12, 2016

Hello,

I tried the 1C:Translator and it runs, but I tried to trigger the onClick event on Mobile using that Template and it does nothing.
So, I think the last option is what you said with CSS. What I need to do is a menu for my application using HTML, but if the buttons are links, the whole HTML field will change in what the link represents when I will click on a link. What can I do?

Profile
#5
Guest
Points::
Joined::

You can add a class for specific links and adjust this class in CSS to make only them look like a button.

Code
<a class="button">...</a>

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.