HTMLfield onClick not working

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Sep 12, 2016
Company:

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!

 
#2
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

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

 
#3
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

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

 
#4
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Sep 12, 2016
Company:

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?

 
#5
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

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>

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.