facebook

Getting src of image in multipage template?

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #346634 Reply

    rick.gommers
    Member

    Please have a look at this image:

    I have a multipage template. The ‘multiPageTmpl25’ as seen in the image replaces templates (from which the user can choose) in my app.

    These templates consists of 2 images, one larger and one smaller. The smaller one has allways the highest number. I want to transfer the source of this image (with the highest number) to another screen. I know how to do that, the thing I need is the src of my image.

    I have onPageChange event which returns the id of the template placeholder, like Tmpl1_25mm (see image above).

    Is it possible to get the src of the image with the highest number which resides in that template placeholder?

    Difficult to explain. I hope you understand it. Thx in advance!

    #346636

    Code_A
    Member

    I am not sure I completely understand, but here is how you can get the source of your image:

    alert($('#m1-screen-image1').attr('src'));

    Here is how you can change an image source:

    $('#m1-screen-image1').attr('src', newImagePath);

    Hope this helps.

    #346638

    rick.gommers
    Member

    Hi Code A,

    Maybe look at the code suggestion below first, before reading my description. I think I make it more difficult then it is..

    Thx for your suggestion.

    The problem is I don’t know the id of the image I want before the user clicks on the template placeholder (Tmpl1_25mm, Tmpl2_25mm, etc).

    I have 60 templates right now with many more to come, so I can’t make an if statement to get the id of every template yet to come.

    Instead, I’d like to receive the id of the image with the highest number, when I click on it’s corresponding template placeholder (Tmpl1_25mm). check the image in previous post!

    Right now, I have an onPageChange event on the parent multiPageTmpl25. This returns the Id of the template placeholder when clicked upon:

    var templateId = ($(newPage).attr('id'));
    templChanged(templateId);
    
    function templChanged(templateId) {
       alert(templateId);
    }

    Alert returns template placeholder as in: screen1-Tmpl1_25mm, screen2-Tmpl5_20mm, etc.

    I want to do something like

    $('#templateId').find('<img>')

    And then return the image with the highest id number.

    #346639

    Code_A
    Member

    I still may be confused, but what about just coming up with a naming convention for each image within the templates? For example, <templateID>_1 & <templateID>_2, etc. This way you would know all the image names for each template.

    #346641

    rick.gommers
    Member

    ah yes naming is a disaster. I’ll have to look at that 🙂

    But I’m thinking way too difficult xD I have my solution:

    function templChanged(templateId) {
        
        alert(templateId);
        var ringImages = $('img', templateId)
    
        var smallImage = ringImages.filter(function(){
          return ($(this).width() < 140) )
          alert(smallImage);
        })
        
    }

    Thx for your help! Together we always find a solution 🙂

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Getting src of image in multipage template?

You must be logged in to post in the forum log in