Element search means to replace getElementById when multiple identical pages are displayed in ons-navigator

Asked 5 months ago, Updated 5 months ago, 12 views

I am studying developing apps for iPhone at Monaca.
On the page displayed as a child screen in ons-navigator, there are the following elements:

<input type="search" id="id1">

I would like to get the value of this tag and give it as the second parameter of pushPage ("self.html", options).

Normally, document.getElementById("id1").value" allows honest access, but cannot be used with multiple elements with the same ID.

I couldn't think of it.

Could you please let me know if there is any usual way to use onsen-ui?

monaca onsen-ui

2022-09-30 11:12

2 Answers

This is a self-answer, but I have found the following alternatives:

As I am a beginner, I am not sure if I understand correctly, so please follow me if you are an advanced person.

Data binding (?) can be done using ng-model instead of id.


    module.controller('searchController', function($scope){
            myNavigator.pushPage('self.html', {keyword:search_keyword});


<ons-navigator var="myNavigator" page="self.html">

<ons-template id="self.html">
        <input type="search" class="search-input"ng-model="search_keyword"/> 


2022-09-30 11:12

In the first place, in javascript,
It can be retrieved as an array using getElements series.
After that, you should be able to control it as you like by identifying the target in the order of the array.




2022-09-30 11:12

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.