Integrate Divi template into already existing React project

Hello everyone!

Yesterday I started using Divi, in order to save time on designing the page and rather focus on the coding part. All things good, but I stuck with the problem that I don’t know how to integrate the styling of certain divi template into my app, whenever I finish it.

I searched everywhere on the internet, but I just cannot find information about it. I see that whenever the component is exported, a JSON object is received, but the problem is that it is really strange and I don’t know how to apply it to certain React component. For example:

   {
  "context": "et_theme_builder",
  "templates": [
    {
      "title": "Default Website Template",
      "autogenerated_title": false,
      "default": true,
      "enabled": true,
      "use_on": [],
      "exclude_from": [],
      "layouts": {
        "header": { "id": 8, "enabled": true },
        "body": { "id": 10, "enabled": true },
        "footer": { "id": 0, "enabled": true }
      },
      "description": "<span class="et-cloud-app-layout-desc-item-global">Default Website Template</span>"
    }
  ],
  "layouts": {
    "8": {
      "context": "et_builder",
      "data": {
        "8": "[et_pb_section fb_built="1" theme_builder_area="post_content" _builder_version="4.24.3" _module_preset="default"][/et_pb_section]"
      },
      "images": [],
      "post_title": "Theme Builder Layout",
      "post_type": "et_header_layout",
      "theme_builder": { "is_global": true },
      "global_colors": null,
      "post_meta": [
        { "key": "_et_pb_use_builder", "value": "on" },
        { "key": "_et_pb_built_for_post_type", "value": "page" },
        { "key": "_et_pb_enable_shortcode_tracking", "value": "" },
        { "key": "_et_pb_custom_css", "value": "" },
        { "key": "_et_pb_gutter_width", "value": "3" },
        { "key": "_et_pb_first_image", "value": "" },
        { "key": "_et_pb_truncate_post", "value": "" },
        { "key": "_et_pb_truncate_post_date", "value": "" },
        { "key": "_et_builder_version", "value": "VB|Divi|4.24.3" }
      ]
    },
    "10": {
      "context": "et_builder",
      "data": {
        "10": "[et_pb_section fb_built="1" _builder_version="4.24.3" _module_preset="default" global_colors_info="{}"][et_pb_row column_structure="1_2,1_2" _builder_version="4.24.3" _module_preset="default" global_colors_info="{}"][et_pb_column type="1_2" _builder_version="4.24.3" _module_preset="default" global_colors_info="{}"][et_pb_accordion _builder_version="4.24.3" _module_preset="default" icon_color="#FFFFFF" hover_enabled="0" sticky_enabled="0"][et_pb_accordion_item title="Your Title Goes Here" _builder_version="4.24.3" _module_preset="default" open="off"]<p>Your content goes here. Edit or remove this text inline or in the module Content settings. You can also style every aspect of this content in the module Design settings and even apply custom CSS to this text in the module Advanced settings.</p>[/et_pb_accordion_item][/et_pb_accordion][/et_pb_column][et_pb_column type="1_2" _builder_version="4.24.3" _module_preset="default" global_colors_info="{}"][et_pb_accordion _builder_version="4.24.3" _module_preset="default" icon_color="#FFFFFF" hover_enabled="0" sticky_enabled="0"][et_pb_accordion_item title="Your Title Goes Here" _builder_version="4.24.3" _module_preset="default" open="on"]<p>Your content goes here. Edit or remove this text inline or in the module Content settings. You can also style every aspect of this content in the module Design settings and even apply custom CSS to this text in the module Advanced settings.</p>[/et_pb_accordion_item][/et_pb_accordion][/et_pb_column][/et_pb_row][/et_pb_section]"
      },
      "images": [],
      "post_title": "Theme Builder Layout",
      "post_type": "et_body_layout",
      "theme_builder": { "is_global": true },
      "global_colors": null,
      "post_meta": [
        { "key": "_et_pb_use_builder", "value": "on" },
        { "key": "_et_pb_show_page_creation", "value": "off" },
        { "key": "_et_pb_built_for_post_type", "value": "page" },
        { "key": "_et_pb_enable_shortcode_tracking", "value": "" },
        { "key": "_et_pb_custom_css", "value": "" },
        { "key": "_et_pb_gutter_width", "value": "3" },
        { "key": "_et_pb_first_image", "value": "" },
        { "key": "_et_pb_truncate_post", "value": "" },
        { "key": "_et_pb_truncate_post_date", "value": "" },
        { "key": "_et_builder_version", "value": "VB|Divi|4.24.3" }
      ]
    }
  },
  "presets": {},
  "has_default_template": true,
  "has_global_layouts": true
}

So how can I integrate that thing into certain React component, for example, let’s say I want to use something from that JSON into this component:

class DetailedExam extends Component {
      constructor(props) {
        super(props);

        this.state = {
          hasStarted: false,
          details: {},
        };

        this.startExam = this.startExam.bind(this);
      }

      startExam() {
        this.setState({
          hasStarted: !this.state.hasStarted,
        });
      }

      componentDidMount() {
        this.setState({ details: this.props.location.state });
      }

      render() {
        return (
          <>
            {this.state.hasStarted ? (
              <App
              // examType={}
              />
            ) : (
              <div className="Front-Page">
                <FrontPageHeader className={"Header"}>
                  <img src={solved_logo} className="Solved-Logo" />
                </FrontPageHeader>
                <div className="Content-Holder">
                  <main className="Main">
                    <h1>Hi</h1>
                    <div>
                      <span>
                        {this.state.details.title}
                        {this.state.details.text}      
                      </span>
                    </div>
                  </main>
                </div>

                <div className="Start-Btn">
                  <button onClick={this.startExam}>Start</button>
                </div>
                <footer className="Footer">
                  <a
                    href="https://solvedeu.com"
                    target="_blank"
                    rel="noopener noreferrer"
                  >
                    <strong>Visit our website</strong>
                  </a>
                </footer>
              </div>
            )}
          </>
        );
      }
    }

    export default () => (
      <DetailedExam params={useParams()} location={useLocation()} />
    );

And is this the way to do it, because I have no clue how to? Maybe there is smoother and more elegant way than just figuring out where to place the converted css.

Thanks for all kind of help!

Cannot read properties of undefined (reading ‘id’) Select 2

I have a Table in which there are multiple select fields . i have used select2 library for this project.

in the First row , when i click on remove x button on the select field , it works fine , but when i add a second row in the table and then populate dropdowns and try to remove a selected item , it gives the error Cannot read properties of undefined (reading ‘id’)

Please help , below is example of a td in which there is a select field . I have multiple select columns in a single row and then multiple rows.

 <td class="line-item-column item-cf group-drop" style="max-width: 180px;">
                                    <div id="ember47" class="ember-view" style="width: 170px;">
                                        <div class="ac-box">
                                            <select style="width: 100%;" class="js-example-basic-single group-dropdown" name="group-dropdown">
                                                <option value="" disabled selected>-Select-</option>
                                            </select>
                                        </div>
                                    </div>

                                </td>


$('.js-example-basic-single').select2({
allowClear: true,
placeholder: 'Select Options',
dropdownAutoWidth: true,
debug:true

});

NPM Error while adding overrides for a dependency

I have multiple dependencies related to a UI framework I am using as below

"@my-ui-fwk/ag-grid-theme": "^1.3.7",
"@my-ui-fwk/core": "1.16.0",
"@my-ui-fwk/data-grid": "^1.0.3",
"@my-ui-fwk/icons": "1.9.1",
"@my-ui-fwk/lab": "^1.0.0-alpha.29",
"@my-ui-fwk/theme": "1.11.0",

Now, I want to ensure that only 1 version of “@my-ui-fwk/core” i.e. “1.16.0” is used.

So when I run npm list, I get below;

$ npm list @my-ui-fwk/core
+-- @my-ui-fwk/[email protected]
+-- @my-ui-fwk/[email protected]
| +-- @my-ui-fwk/[email protected]
| `-- @my-ui-fwk/[email protected]
|   `-- @my-ui-fwk/[email protected] deduped
`-- @my-ui-fwk/[email protected]
  `-- @my-ui-fwk/[email protected]

Now to fix i.e. ensure that only 1 version of “@my-ui-fwk/core”, I add the following to my package.json

"overrides": {
    "@my-ui-fwk/data-grid": {
      "@my-ui-fwk/core": "$@my-ui-fwk/core"
    },
    "@my-ui-fwk/lab": {
      "@my-ui-fwk/core": "$@my-ui-fwk/core"
    }
}

However, after adding above overrides and when I do npm install again and run npm list, I am getting below error;

npm list @my-ui-fwk/core
npm ERR! code ELSPROBLEMS
npm ERR! invalid: @my-ui-fwk/[email protected] D:my-ui-webnode_modules@my-ui-fwklabnode_modules@my-ui-fwkcore
[email protected] D:my-ui-web
+-- @my-ui-fwk/[email protected] overridden
+-- @my-ui-fwk/[email protected] overridden
| +-- @my-ui-fwk/[email protected] deduped
| `-- @my-ui-fwk/[email protected] overridden
|   `-- @my-ui-fwk/[email protected] deduped
`-- @my-ui-fwk/[email protected] overridden
  `-- @my-ui-fwk/[email protected] invalid: "1.16.0" from node_modules/@my-ui-fwk/lab overridden

Please let me know if the above is not the correct way to add ‘overrides’

How to print the result from a loop in one line on the console in Javascript

I’m trying to print out the result from a loop onto the console but it keeps printing on a new line instead of printing everything on the same line.

this is the output I’m expecting:

“…17°C in 1 days … 21°C in 2 days … 21°C in 3 days “

but this is the output i keep getting:

“… 17°C in 1 days

… 21°C in 2 days

… 23°C in 3 days”

I’ve tried most of the answers I found but they are not working.

const arr =[17, 21, 23];
function printForcast(arr) {
  
  
  for (let i = 0; i < arr.length; i++) {
    let days = i;

   if(i <= days){
    days +=1;
    
   }
 console.log(`... ${arr[i]}°C in ${days} days`); 
 }
  return arr;
}

printForcast(arr);
<!DOCTYPE html>

Server side processing cell styling

I am requesting for some help on my server side processing jQuery script

What i need is to

Add td class

Get cell values

And change the cell styling

Below is my script i have tried

Am getting this error

Uncaught SyntaxError: unexpected token: identifier

<script type = "text/javascript">
    $(document).ready(function() {
        $("#contact-detail").dataTable({
            "processing": true,
            "serverSide": true,
            "ajax": {
                "url": "scpp.php",
                "type": "POST",
                "dataType": "json"
            },

            rowCallback: function(row, data, index) { // get cells

                $('#td_id').addClass('td_style'); // add td class

                var currentRow = $(this).closest("tr");  // help to select the current row.

                if (data[0]) { // for first cell
                    var col1 = $(row) currentRow.find("td:eq(0)").text(); // find first cell value
                    $(this).html('<a href="order.php?d=' + col1 + '" role="button" class="btn"> <span class="spinn" role="status"></span>>' + col1 + '</a>') // make it look like this
                }
                if (data[1]) { // for second cell
                    var col2 = $(row) currentRow.find("td:eq(1)").text(); // find second cell value
                    $(this).html('<img src="img/' + col2 + '" class="image" alt="Trulli">') // make it look like this
                }
                if (data[2]) { // for third cell
                    var col3 = $(row) currentRow.find("td:eq(2)").text(); // find third cell value
                    $(this).html('<i class="fa fa-user-circle-o"></i> ' + col3 + ' ') // make it look like this
                }
            }
        });
    }); <
</script>

How do I intent a post on social media app?

On my website I have the following custom JS code (have replaced the actual links with //custom link for this example):

<script>
document.getElementById("fb-button").addEventListener("click", function() {
    var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
    var facebookURL;
    
    if (isMobile) {
        // Use the Facebook app URL if on mobile
        var postURL = encodeURIComponent("// custom link");
        facebookURL = "fb://share/?text=Check%20out%20this%20link!&href=" + postURL;
    } else {
        // Use the web URL for sharing if on desktop/laptop
        facebookURL = "https://www.facebook.com/sharer/sharer.php?u=//custom link";
    }
    
    // Redirect the user to the determined Facebook URL
    window.location.href = facebookURL;
});
</script>

What I want to achieve is an intent Facebook post with the link of a post I want people to share by clicking my button. The code works fine for desktop Facebook, but on mobile it only creates an empty post intent without text or link. I wonder if this is even possible, and if so, how could I achieve this?

Bun FFi function fails when I return a null terminated slice from ziglang

I’m implementing a ziglang function to generate a ulid. So far it works when called via a main function. However, when using it with Bun’s FFI it fails. (console.log) is an empty string.

Zig

const std = @import("std");

pub fn reverse(source: []const u8, target: []u8) void {
    for (source, 0..) |c, i| {
        target[source.len - 1 - i] = c;
    }
}

fn toBase32(bytes: []const u8, str: []u8) void {
    const BASE_32_CHARACTERS = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";

    var bitBuffer: u16 = 0;
    var bitCount: u4 = 0;
    var strIndex: usize = 0;

    for (bytes) |byte| {
        bitBuffer = (bitBuffer << 8) | @as(u16, byte);
        bitCount += 8;

        while (bitCount >= 5) {
            bitCount -= 5;
            const index = (bitBuffer >> bitCount) & 0x1F;
            str[strIndex] = BASE_32_CHARACTERS[index];
            strIndex += 1;
        }
    }

    // Handle any remaining bits
    if (bitCount > 0) {
        const index = (bitBuffer >> (5 - bitCount)) & 0x1F;
        str[strIndex] = BASE_32_CHARACTERS[index];
    }
}

pub export fn ulid() [*:0]const u8 {
    //  01AN4Z07BY      79KA1307SR9X4MV3
    // |----------|    |----------------|
    //   Timestamp          Randomness
    //     48bits             80bits

    const seed = @as(u64, @intCast(std.time.nanoTimestamp()));
    var rng = std.rand.DefaultPrng.init(seed);

    // 1. 48-bit timestamp
    const current_timestamp = std.time.milliTimestamp();

    // change std.mem.toBytes output order from little-endian to big-endian
    var timestamp: [6]u8 = undefined;
    reverse(std.mem.toBytes(current_timestamp)[0..6], timestamp[0..]);

    // 2. 80 bits of pseudo-random data
    var random_data: [10]u8 = undefined;
    for (0..10) |i| {
        random_data[i] = rng.random().uintAtMost(u8, 255);
    }

    // change std.mem.toBytes output order from little-endian to big-endian
    var randomness: [10]u8 = undefined;
    reverse(&std.mem.toBytes(random_data), randomness[0..]);

    // 3. Concatenate the above to form a 128-bit ULID
    var uint8_array: [27:0]u8 = undefined;
    toBase32(&timestamp, uint8_array[0..]);
    toBase32(&randomness, uint8_array[10..]);

    // null terminator
    uint8_array[26] = 0;
    return &uint8_array;
}

JavaScript code

import { join } from "path";
import { dlopen, FFIType, suffix } from "bun:ffi";

export const ulid = () => {
    const lib = dlopen(join(process.cwd(), "bin", `libulid.${suffix}`), {
        ulid: {
            args: [],
            returns: FFIType.cstring,
        },
    });

    const str = lib.symbols.ulid();

    console.log(str);
};

But writing a simple function that returns a static string, it works as expected.

fn hey() [*:0]const u8 {
    return "Hello, World!";
}

pub export fn hello() [*:0]const u8 {
    return hey();
}
export const hello = () => {
    const lib = dlopen(join(process.cwd(), "bin", `libhello.${suffix}`), {
        hello: {
            args: [],
            returns: FFIType.cstring,
        },
    });

    const str = lib.symbols.hello();

    console.log(str);
};

PS: I’m new to zig-lang (systems programming) and experimenting with low-level programming in my JS apps.

Extending a JavaScript ES6+ class that explicitly returns an object in its constructor

I’m having issue with extending a Javascript ES6+ class that returns an object from the constructor.

Take for example:

class Base {
  constructor() {
    return {name: "base"}
  }
}

class Extension extends Base {
  constructor() {
    super()
  }

  saySomething() {
    console.log("What do you want me to say?")
  }
}

Creating a new instance of Extension class and calling saySomething fails with an error, because for whatever reason, which I think is related to base class returning a value in its constructor, the method saySomething does not seem to exist (in fact nothing other than just what belongs to base class) on Extension class prototype.

The major problem that has led to this base problem was me trying to create an extended PrismaClient as seen here, with client extension in NestJS, this certain way which results in other methods on the PrismaService class to not exist on the prototype chain.


function PrismaExtended() {
  type Params = ConstructorParameters<typeof PrismaClient<Prisma.PrismaClientOptions, Prisma.LogLevel>>;
  const client = (...args: Params) =>
    new PrismaClient<Prisma.PrismaClientOptions, Prisma.LogLevel>(...args).$extends({
      result: {
        $allModels: {
          toJSON: {
            compute(data: BaseEntity) {
              return <T extends typeof data = typeof data>() => {
                return Object.assign({}, data, {
                  sn: typeof data.sn === 'bigint' ? data.sn.toString() : data.sn,
                }) as unknown as Omit<T, 'sn'> & { sn: string };
              };
            },
          },
        },
      },
    });

  class PrismaExtended {
    constructor(...args: Params) {
      return client(...args);
    }
  }

  // Object.setPrototypeOf(PrismaExtended, PrismaClient.prototype);
  return PrismaExtended as new (...args: Params) => ReturnType<typeof client>;
}

@Injectable()
export class PrismaService extends PrismaExtended() implements OnModuleInit, OnModuleDestroy {
  private retries: number = 0;
  constructor(
    private readonly logger: AppLogger,
    configService: ConfigService,
  ) {
    super({
      log: pickFrom(configService, 'app.status') !== NodeEnv.PROD ? ['query'] : undefined,
      transactionOptions: { timeout: 60_000 },
    });
  }

  /**
   * Check if an error is as a result of a precodition necessary to run an
   * operation not being matched.
   *
   * @param e The error to check
   * @returns boolean
   */
  isUnmatchedPrecondition(e: unknown): e is PrismaClientKnownRequestError {
    return e instanceof PrismaClientKnownRequestError && e.code === PrismaErrorCode.UNMATCHED_PRECONDITION;
  }
}

Here the method, isUnmatchedPrecondition, and any other method added don’t exist at runtime.

Real time data not display it return an error message: {“error”: “‘QuerySet’ object has no attribute ‘body'”}

I like to implement real time data display in django app using Ajax, i want to enable user to be able to see what they are writing in real time, to do this, i’m using django JsonResponse, using the below method:

def get_real_time_data(request):
    if request.method == 'POST':
        body = request.POST.get('body')

        try:
            question = Question.objects.filter(body=body)
            if question is not None:
                content = question.body
                response_data = {
                    'content': content
                }
                return JsonResponse(response_data)
            else:
                return JsonResponse({'error': 'No content found for the given body'}, status=404)
        except Exception as e:
            return JsonResponse({'error': str(e)}, status=500)
    else:
        return JsonResponse({'error': 'Invalid request method'}, status=400)

Using the above method, it’s means, every time, a user started writing something in the form, the data will be displayed in real time, but I don’t know why the data does not display, instead, it return an error message in the browser console:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)
question/:89 {"error": "'QuerySet' object has no attribute 'body'"}
error @ question/:89
:8000/get-real-time-data/:1 
 Failed to load resource: the server responded with a status of 500 (Internal Server Error)
question/:89 {"error": "'QuerySet' object has no attribute 'body'"}
error @ question/:89
jquery.min.js:2 
POST http://127.0.0.1:8000/get-real-time-data/ 500 (Internal Server Error)

my template:

<div class="container">
        <div class="row">
            <div class="col">
                <div class="card">
                    <div class="card-body">
                        <form action="" method="post">
                            {{ form }}
                            <div id="id_value"></div>
                            <input type="submit" class="btn btn-primary">
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script>
        function getCookie(name) {
            let cookieValue = null;
            if (document.cookie && document.cookie !== '') {
                const cookies = document.cookie.split(';');
                for (let i = 0; i < cookies.length; i++) {
                    const cookie = cookies[i].trim();

                    if (cookie.substring(0, name.length + 1) === (name + '=')) {
                        cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                        break;
                    }
                }
            }
            return cookieValue;
        }

        $(document).ready(function() {
            function updateRealTimeData() {
                $.ajax({
                    url: "{% url 'get_real_time_data' %}",
                    type: 'POST',
                    dataType: 'json',
                    headers: {'X-CSRFToken': getCookie('csrftoken')},
                    data: {},
                    success: function(data) {
                        $('#id_value').text(data.content);
                    },
                    error: function(xhr, status, error) {
                        console.error(xhr.responseText);
                    }
                });
            }
            setInterval(updateRealTimeData, 5000);
        });
    </script>

my models:

class Question(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
    title = models.CharField(max_length=90)
    body = models.TextField()

Given a child how to get it’s parent in a HTML dom?

Given a child how to get its parent in an HTML dom? For example given a child<h1 class="children">Hi! I'm children</h1> It will return <div class="parent">
<h1 class="children">Hi! I'm children</h1> </div> Of course, this is just an example from the given HTML DOM. But suppose the HTML DOM will be dynamic.

Example HTML:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Document</title>
  </head>
  <body>
    <div class="head">
      <h1>Hi! I'm Heading</h1>
      <main>
        <div class="parent">
          <h1 class="children">Hi! I'm children</h1>
        </div>
      </main>
      <div class="parent2">
        <h1 class="children2">Hi! I'm children</h1>
      </div>
    </div>
  </body>
</html>

I wonder if there is any method by playwright to do that? By code only return the child but how can I get both parents with the child if it’s nested;

import { chromium } from "playwright";

(async () => {
  const browser = await chromium.launch({ headless: false });
  const page = await browser.newPage();

  await page.goto("https://www.google.com");
  await page.fill("textarea.gLFyf", "Dog");
  await page.keyboard.press("Enter");

  await new Promise((resolve) => setTimeout(resolve, 1000));

  for (const input of await page.getByText("Dog").all()) {
    const htmlCode = await input.evaluate((node) => node.outerHTML);
    
  }
})();

Fetch response in the ckeditor ai plugin

Is there a method to effectively manage the response from the Fetch AI plugin within CKEditor 5? Currently, I’m only able to access the content using ‘ondata,’ which is limiting. While I attempted to utilize ‘ondata,’ I found that it only provides the response content

How do I recognize when a user has stopped talking in JS SpeechRecognition API?

I made a SpeechToText application using the JS SpeechRecognition API. In my application there is a button and an input, when the user clicks on the button, I start listening to the user’s speech and write what they say to the input. When the user starts talking, I show a text in a span above the input. If the user takes a short break, I want to hide a span above the input. Then if the user continues talking, I want to show this span again. So I want to detect when the user takes a break, how can I do this?

HTML

<div id="container">
    <input type="text" id="textInput">
    <button id="startButton">Start</button>
    <div id="speechOutput"></div>
</div>

CSS

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #f4f4f4;
}

#container {
    text-align: center;
}

#speechOutput {
    margin-top: 20px;
    font-style: italic;
    color: #888;
}

JS

const recognition = new webkitSpeechRecognition() || new SpeechRecognition();
recognition.lang = 'en-US';

const textInput = document.getElementById('textInput');
const startButton = document.getElementById('startButton');
const speechOutput = document.getElementById('speechOutput');

recognition.onstart = function() {
  speechOutput.innerText = 'Speech started...';
};

recognition.onresult = function(event) {
  const speechResult = event.results[0][0].transcript;
  textInput.value = speechResult;
};

recognition.onend = function() {
  speechOutput.innerText = '';
};

startButton.addEventListener('click', function() {
  recognition.start();
});

App JS Fiddle

Why would somebody create an object like this?

I found some odd looking code at work and I’m trying to understand why it’s done like this. Is there a case where this is more efficient? Or is it maybe just somebody bored one day, having some fun?

var dataPost = jQuery.parseJSON( '{"report":"", "query":""}' )
dataPost['report'] = eReportData;
dataPost['query'] = sbody;

data-target not working in html.slim partial in ruby on rails

this is my file _stars_percent.html.slim
`.rating-details class=”#{product.id}-rating-details-#{disp_value} #{classes}” style=”display: #{disp_value}”
.text-center.mb-20.font18
= avg_rating
| out of 5 stars

- (5).downto(1) do |i|
    .rating-bar-wrapper.mb-10
        - percentage = product.rating_percentage_of(i)
        span.pull-left.width-42
            = i
            |   Stars
        .rating-bar-container.inline-block
            .rating-bar.inline-block.bg-light id="bar_#{i}" style="width: #{percentage}%;"
        span.pull-right
            = percentage
            | %

- if reviews_count != 0 && disp_value == 'none'
    .text-center.pt-10      
        span.text-blue.scroll-to data-target='#reviews'
            | See all 
            = reviews_count
            |   reviews `

and this is my file _review_product.html.slim

  • unless @ratings_with_parent_sku.blank?
    #reviews
    .container
    h2.heading.text-center-in-mobile Road Ready Overall Ratings and Reviews
    hr

    • unless @ratings_with_parent_sku.blank?
      • i = 0
        .container
        = hidden_field_tag :total_reviews, @ratings_with_parent_sku.length
        .row.review
        .col-md-3.col-xs-12
        = render ‘spree/shared/all_product_rating’

        .col-md-9.col-xs-12
        .row#reviews-container
        – @ratings_with_parent_sku.each do |rate|
        = render ‘spree/user_product_rating/review’, rate: rate, i: i
        – i+=1
        .row
        .col-lg-12.mt-20.col-xs-12
        .text-center
        .show-more-container
        – if @product.present?
        = link_to ‘Load More’, ”, class: ‘load-more’, data: { url: show_more_reviews_product_path(@product) }
        = link_to ‘See All’, reviews_path, class: ‘load-more2’, target: ‘_blank’
        br

    • else
      .row
      .col-md-12.col-sm-12.col-xs-12.mb-20
      h3.text-lighter.text-center Not Rated Yet.

why data-target not show #reviews?

i had tried to change data-target to aria-controls but still it not worked …
following error i am getting in the console

Uncaught TypeError: Cannot read properties of undefined (reading 'top') at HTMLSpanElement.<anonymous> (initial-f87a2d9bf4d9325b397986984b3b3bb83dfab8f5f79a6250af7dc7bd4ce7f53d.js:306:38) at HTMLDocument.dispatch (all_taxons-df9a2d1ac7af95bc5aae29ee16b6b7aff1e73a12ef1904872ca729dfdd7e262f.js:5227:27) at elemData.handle (all_taxons-df9a2d1ac7af95bc5aae29ee16b6b7aff1e73a12ef1904872ca729dfdd7e262f.js:4879:28)