• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Does RoboHelp 9 support jQuery?

Explorer ,
Jan 20, 2016 Jan 20, 2016

Copy link to clipboard

Copied

Hi,

I'm having trouble running a jQuery script in RH9.

I'm trying to run a jQuery script in RH9 but it doesn't do anything in the RH Previewer (Ctrl+W). When I generate a chm, the topic displays an error message when displaying the topic.

The short script I'm running is this:

$.get('rhvariable.apj', function(data)

{

   var xml_data = data;

   $(xml_data).each(function(){

        if($(this).find('name').text() == 'Laser_Version') {

            var release_Version = ($(this).find('value').text());

            alert('The current Release Version is: ' + release_Version);

        }

    });

});

Essentially, I'm opening the XML-based User Defined Variable .apj file and locating and returning the version # of our product from it that I'll use to insert into a form that comes up for user feedback.

The script runs beautifully when the file's opened in IE11, Chrome or FireFox so I know it's correct. However, when I run it from a RH9 compiled help (.chm), I get this error message:

I originally had the initial line as "jQuery.get" which gave me the same error only it flagged the jQuery property as undefined.

When I changed it to "$.get" I get the above error message.

I also tried to enclose it within a function:

$function()

{

   $get(...

   {

       .

      .

      .

   ]);

});

The Error description was simply '$' is undefined

If I run it within the RH9 Previewer (Ctrl+W), nothing happens - no error message but the page does display.

I'm using the latest jQuery min file: "jquery-1.12.0.min.js"

Thanks in advance!!!

Views

886

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 21, 2016 Jan 21, 2016

Copy link to clipboard

Copied

jQuery is not included in RoboHelp. You can include it manually by adding a reference to jQuery in the master page or on your topics. You will need to include the jQuery library as a baggage file to get it in the output.

Also, the rhvariable.fpj file is not available once you generate the output. So in the CHM this script will never work.

What are you trying to achieve with this script? There may be better solutions than doing this with jQuery,

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 25, 2016 Jan 25, 2016

Copy link to clipboard

Copied

Hi William, thank you for your response.

Yes, I understand jQuery isn't included in RH.

  • I included the jQuery.js file as a baggage file in my project.
  • I made the necessary <script> call to it in my .htt master page's header - I actually placed the call in the <?rh-region_start type="header" ?> section of the code so it looks like this:

<?rh-region_start type="header" ?>

    <script src="jquery.js" type="text/javascript"></script>

<?rh-region_end type="header" ?>

  • I've added the rhvariable.fpj (actually rhvariable.apj) as a baggage file and I verified it gets included in the chm compilation by decompiling the chm.

What we are trying to do is grab two User Defined Variables (UDV) to incorporate into the Subject line of an e-mail form using a combination of straight javascript and jQuery.

From the javascript, in the footer of each of our topics, the link "Send Feedback on this Topic" is displayed. Click the link to send feedback related to the topic.

When clicked, an e-mail form from their default e-mail app is displayed:

The Subject line incorporates the two UDV's - UDV #1 is the product version, UDV #2 is the product name.

We got it to work somewhat by creating two <div> containers that encapsulate the two UDV's, applied an id (id="version" and id="product") to the div's. We then use jQuery to get the respective <div> text, then use jQuery to hide the <div> text so they don't appear in the topics...UGH! Once that's done, the feedback script appears to be working ... for our smaller Laser help project anyways, and only for html output (.chm). When we do Web output, only the initial "PC-DMIS " appears in the Subject line...ARGH!!! But the script is working with the RH previewer (Ctrl+W)...ERRR!!!

The e-mail form from the .chm feedback link displays properly as shown in the last image above.

The e-mail form from the Web version displays thusly:

To further complicate the issue, we have a large help system where we can't get the script to run at all. It's as if RH doesn't acknowledge that these updates were made to the .htt and doesn't apply the master sheet changes to the topics. If I open a topic up in RH and manually set the topic's Master Sheet property to None then back to our .htt Master sheet, it updates and the one topic does work when using RH's previewer or when the chm is generated. I'd have to do this to over 2000 topics and then there's having to push all these changes up to our source control server when all I wanted to do is update a single .htt file. I know I can do this in one swoop (actually two swoops - one swoop to set it to None, the second swoop to set it back to the .htt we're using) within the Topic List pod, but why do I have to go through all this just to get a simply jQuery script to work?

We are planning on upgrading to the latest version of RH at some point this year - not sure if that will help but we're counting on it.

By all means, if you have a better solution I would be very appreciative of your insight.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 25, 2016 Jan 25, 2016

Copy link to clipboard

Copied

Hi Steve (Steve and I are on the same team),

Regarding the preview Ctrl + W in RH not working, the problem isn't with jQuery. I don't know if it's anything to do with RH at all. From what I can tell, RH supports jQuery just fine though I haven't looked into the issue you mentioned about the larger help project.

The problem with the variables not showing up in the preview screen has to do with the use of string encoding via the escape function in the document.write statement:

document.write('<a href="#">Back to Top</a> | <a href="mailto:team_email@somecompany.com' + '?subject=' + escape(mailSubject) + '&body=' + escape(mailBody) + '">' + mailDisplay + '</a>');

The escape function is used with string encoding. It's a deprecated function. Newer code should use encodeURI to encode strings and decodeURI to decode strings.

If you remove the escape function from the mailSubject and mailBody variables (or decode the strings), it works as shown here.

So, one question is, do we need to encode these strings? Maybe that's something the forum can help answer. I don't really know enough about encoding to know. We aren't sending them over the Internet per se, we're just providing a clickable link (the href with mailto attribute) that opens up the email client. Our users choose to click the Send button in their their email client's send to send the feedback once they type their feedback.

Info on encoding from w3schools: HTML URL Encoding Reference

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 26, 2016 Jan 26, 2016

Copy link to clipboard

Copied

LATEST

Steve, as to why you have to reapply the .htt for jQuery to work in Core, is because the call to the jQuery is in the header section of the .htt, but the existing Core topics do not use a header, so only new topics will pick up the reference.

Once you reapply the .htt it inserts the header into those topics.

That said, you can just apply the jQuery .js call in the footer of the .htt for all cases since all our help projects use the footer. I tested it and it works.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
RoboHelp Documentation
Download Adobe RoboHelp